Unable to restart Apache, getting error: apache2: bad user name ${APACHE_RUN_USER}

I am getting this error trying to restart Apache, does anyone know how to fix this? Thanks,


To fix this problem, you have to make the changes to two separate files.

First, edit /etc/apache2/apache2.conf, adding these lines:

User www-data
Group www-data

Second, edit /etc/apache2/envvars, adding these lines:

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

This will set your apache2 ENV vars for the current session and allow you to use the apache2 binary without modifying your config:

source /etc/apache2/envvars

/etc/apache2/envvars

Is simply a script that sets some environment variables. When you use apachectl it processes this before launching apache2 itself. If you want to invoke apache2 from the terminal, you'll need those vars as well.

So invoking source /etc/apache2/envvars sets up the variables allowing apache2 to work outside of apachectl.

You could potentially set these up in a number of other ways. E.g. invoke envvars when you login.