Adding user to Apache group www-data in Ubuntu

While working in Ubuntu Linux, if you run into a group permissions issue involving Apache2 then you may need to adjust user group settings. The default Apache group in Ubuntu is www-data. To solve the problem, the user needs to be a member of the www-data group. The example below will use the username “bob” for demonstration purposes.

Add an existing user to the www-data group

$ sudo usermod -a -G www-data bob

To verify, use the groups command:

$ groups bob
bob: adm bob cdrom sudo dip www-data plugdev lpadmin sambashare

Create a new user and add them to the www-data group

$ sudo useradd -g www-data bob

To verify, use the groups command:

$ groups bob
bob: www-data


Show Current User Account In Linux

If the user has changed their prompt to some other format we need to try something else. The who command will give us the information we are looking for.


The output from who gives you the name of the current user, the terminal they are logged in at, the date and time when they logged in. If it is a remote session, it also tell us where they are logged in from.

By comparison, the whoami command provides a very pithy answer:


You can get the same one-word answer by echoing the $USER environment variable to the screen.

echo $USER

The one-letter command w requires less typing and provides more information.


The w command provides us with the user name which is what we wanted, and a bonus set of data for that user. Note that if there are multiple users logged into the Linux system, the w command will list them all. You’d need to know which terminal the user you were interested in had logged in on. If they’ve logged directly onto the Linux computer itself, that’ll be pts/o, so look for :0 in the output from w .

The w command provides the boot time, uptime and average load for the previous five, ten and fifteen minutes, and the following information regarding the current user.

  • USER: The user name.
  • TTY: The type of terminal they are logged in at. This will usually be a pts (a pseudo-teletype). :0 means the physical keyboard and screen connected to this computer.
  • FROM: The name of the remote host if this is a remote connection.
  • LOGIN@: The time at which the user logged in.
  • IDLE: Idle time. This shows ?xdm? in the screenshot because we’re running under an X-windows Display Manager, which does not provide that information.
  • JCPU: Joint CPU time, this is the CPU time used by all processes that have been attached to this tty. In other words, the total CPU time of this user in this logged in session.
  • PCPU: Process CPU time, this is the CPU time used by the current process. The current process is named in the WHAT column.
  • WHAT: The command line of this user’s current process.

Now that we know who this user is, we can obtain more information about them. The id command is a good place to start. Type id, a space, the name of the user and press enter.

id dave

This gives us their user ID (uid), group ID (gid) and the groups they’re a member of. A less cluttered display of the groups can be obtained by using the groups command.

groups dave


Running PHP Script From The Command Line

To run php interactively:

(So you can paste/write code in the console.)

php -a

To make it parse a file and output to the console:

php -f file.php

Parse a file and output to another file:

php -f file.php > results.html

Do you need something else?

To run only a small part, one line or like, you can use:

php -r '$x = "Hello World"; echo "$x\n";'

If you are running Linux then do man php at the console.

If you need/want to run PHP through fpm (FastCGI Process Manager), use cli fcgi:

SCRIPT_NAME="file.php" SCRIP_FILENAME="file.php" REQUEST_METHOD="GET" cgi-fcgi -bind -connect "/var/run/php-fpm/php-fpm.sock"

Where /var/run/php-fpm/php-fpm.sock is your php-fpm socket file.


Working With Php.Ini

PHP settings are controlled by a file named ‘php.ini’. The configuration file is read when Apache web server starts. To change the default PHP settings, you should edit the ‘php.ini’ file and restart your web server.

Out-of-the-box, PHP settings work pretty well but customizing the configuration file allows you to select what can work best for you depending on your hardware architecture and software design.

In this guide, we are going to show you how to edit the basic PHP settings on your Apache web server running on Ubuntu 18.04 VPS.


  • A VPS Plan (visit HostAdvice’s VPS reviews for the best VPS providers)
  • A non-root user with sudo privileges
  • Apache web server
  • PHP

Step 1: Determine the Location of your php.ini File

From time to time, you will need to manage the critical php.ini file. The file location may vary a bit depending on the PHP version running on your server.

The configuration file is located on:


For instance, if you are running PHP 7.0, the file will be located on:


The same case applies to PHP 7.2. You can find the configuration file at:


Step 2: Opening the PHP configuration file for editing

Once you determine the location of your file, the next step is editing it using a nano editor. Use the command below to open the file:

$ sudo nano php_ini_file

For instance:

$ sudo nano /etc/php/7.2/apache2/php.ini

Step 3: Making changes on the php.ini file

As mentioned at the beginning of the article, the default PHP settings may work for the majority of websites or web applications. However, your environment may demand some values to be tweaked a bit to ensure that your website is running smoothly.

In most cases, you will be editing the below PHP settings:

PHP max_execution_time

This sets the maximum execution time in seconds that a PHP script is allowed to run before it is terminated. Sometimes, you might have demanding scripts that should run for a few minutes and you need to change this value. The default value is 30 seconds but you can set it to a larger value

Default value:

max_execution_time =30

Change to any value e.g. 1800

max_execution_time =1800

PHP upload_max_filesize

The default value for this directive is 2M (two Megabytes). This value controls the maximum size of files that you upload using PHP scripts. Sometimes, it is necessary to change this value if you anticipate uploading big files.

For instance, if you are uploading a large database via phpMyAdmin, you will need to change this value.

Default value:


Change to a large value e.g. 16M


PHP post_max_size

This value limits the amount of data allowed on post data. It usually affects PHP scripts that use a lot of web forms. The value also controls files uploaded via a PHP script, hence, it should always be larger than ‘upload_max_filesize’. The default value for ‘post_max_size’ is 8M.

Default value:

post_max_size =8M

Customize it depending on your needs e.g.

post_max_size =32M

PHP memory_limit

The default value for PHP 7.2 ‘memory_limit’ is 128M. Sometimes, poorly written PHP scripts may consume a lot of server’s memory and affect other applications running on your VPS. To avoid this, PHP ‘ memory_limit’ controls the amount of memory allocated to a script.

Default value

memory_limit = 128M

Custom value example

memory_limit = 256M

You can also use -1 if you want to allocate an unlimited amount of memory to your PHP script depending on the available RAM on your VPS

memory_limit = -1

PHP Error Reporting Settings

You can control the behavior of error reporting in PHP using the below directives:

display_errors:>  Set this value to ‘On’ or ‘Off’ depending on whether you want PHP to display errors when scripts are run. In PHP 7.2 the default value is ‘Off’

display_errors = Off

You can turn error reporting on by changing the value to ‘On’:

display_errors = On

log_errors: This value tells whether errors from a script should be saved on the server’s log file. Instead of displaying errors to regular users in a production environment, you should log them. The default value in PHP 7.2 is ‘On’

log_errors = On

You can switch error logging off by changing the value to:

log_errors = Off

error_reporting:  This directive dictates the error reporting level. For PHP versions greater than 5.3, the default value is ‘E_ALL & ~E_DEPRECATED & ~E_STRICT’

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

You may change the value depending on the errors that you want to be reported. For instance, to include notices, use the value below

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE

PHP Date/Time settings

You can also change the default timezone used by PHP scripts.

Find the line:

$ ; date.timezone=

Uncomment it by removing the semicolon and then enter your preferred time zone. You can check the list of support time zones on the official PHP website (

For instance, if you want to change the time zone to New York City, use the value below:

date.timezone= “America/New_York”

Once you finish editing the php.ini file, press CTRL + X, Y and hit Enter to save the changes. You should also restart Apache for the settings to be reloaded using the command below:

$ sudo service apache2 restart

Start, Stop, or Restart Apache Server on Ubuntu

Start Apache Web Server

For Ubuntu users with versions 16.04 and 18.04 and Debian 9.x users, use the following commands in the terminal window to start Apache:

sudo systemctl start apache2

Check status to see whether Apache is enabled with the command:

sudo systemctl status apache2

Stop Apache Web Server

Use the following commands in the terminal window to stop Apache:

sudo systemctl stop apache2

Check status to see whether Apache is disabled with the command:

sudo systemctl status apache2

Restart Apache Web Server

To restart Apache use the command:

sudo systemctl restart apache2

What is Localhost?

In computer networking, host means a “server”. Just like you can put a website on the internet by hosting it on a server, you can make your own computer that server. This connection is called loopback. The IP address for that loopback is

If you’ve put a website on the internet before, then you’ve dealt with hosting companies like Heroku, Hostinger, Netlify, and many others. These are what I refer to as “remote hosts” or virtual servers.

If you’ve served a website on your computer so you can test it without connecting to the internet, what you’re dealing with is a localhost.

So, by definition, localhost is the computer or hostname currently making a request to itself. In this case, the computer is also the virtual server.

What is the IP Address

If you want to visit a website, you type the website address to your browser’s address bar, for example,

The Domain Name Server (DNS) matches the address to a numeric IP address corresponding to that name.

Localhost is not an exception to this. So, if you type localhost to your browser’s address bar, it transforms to the IP address

This IP address is reserved for local servers on computers, so you will never find another IP address that starts with 127.


Downloading Videos As Audio Using YT-DLP

As you will more than likely be wanting the best quality audio the format (-f) selector will be for best audio (ba).

yt-dlp -f ‘ba’ -o ‘%(id)s.%(ext)s’

To save as the video title change %(id)s.%(ext)s to '%(title)s.%(ext)s' to save. For a custom filename songname.%(ext)s.

With YouTubes VP9 codec this file will most likely be .webm or .opus extension.

Saving video as an MP3 file

To save the highest quality audio as an mp3 file you need to define --audio-format mp3 with -x which is extract audio

$ yt-dlp -f 'ba' -x --audio-format mp3  -o '%(id)s.%(ext)s'


Less On Linux ::: Navigating With Less Command

Use these keys to move and search through the text file.

  • Move forward one line: Down Arrow, Enter, e, or j
  • Move backward one line: Up Arrow, y, or k
  • Move forward one page: Space bar or Page Down
  • Move backward one page: Page Up or b
  • Scroll to the right: Right Arrow
  • Scroll to the left: Left Arrow
  • Jump to the top of the file: Home or g
  • Jump to the end of the file: End or G
  • Jump to a specific line: Type the line number  and then hit “g”
  • Jump to a percentage way through the file: Type the percentage and then hit “p” or “%.” (You can even enter decimal values, so to jump to the point 27.2 percent through the file, type “27.2” and then hit “p” or “%.”  Why would you want to use decimals? I honestly have no idea.)
  • Search forward: Hit “/” and type your search, like “/Jekyll”, and press Enter
  • Search backward: Hit “?” and type your search, like “/Hyde”, and press Enter
  • Next matching search item: n
  • Previous matching search item: N
  • Quit: q