Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
what command did you try to restart apache ? –  sagarchalise May 4 '12 at 5:34
Are you using sudo apache2? Try apache2ctl instead. See this answer: askubuntu.com/a/147065/56343 –  XåpplI'-I0llwlg'I - May 8 '13 at 6:03
do a source envvars & then run your command. –  user160453 May 21 '13 at 1:15

6 Answers 6

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:

share|improve this answer
The first block can probably keep referencing the environment variables; the crucial step is defining them in /etc/apache2/envvars! –  Ingo Karkat Jul 30 '13 at 9:23
Actually, my environment variables (Ubuntu 12 VPS which I don't have a lot of control over) were set up correctly and were not referenced. The User www-data is the fix that worked for me. –  Daniel Chapman Jan 6 at 0:51

A temporary fix (that I used) was to edit the file in /etc/apache2/apache2.conf. Look for this:


and change it to this:

User www-data
Group www-data

For whatever reason, apache2 isn't looking in envvars to get the appropriate environment variables. The real answer to why this is happening is to track down why envvars isn't being consulted.

share|improve this answer
Probably an upgrade that did not affect configuration. /etc/init.d/apache2 is supposed to load this variable. You can manually extract the conffile from a deb file and replace it. –  Lekensteyn Jun 5 '12 at 8:17
Really? What does your /etc/apach2/apache2.conf say around line 144? I'm wondering what it has for User and Group. This seems bizarre to me because envvars defines it and its right next to apache2.conf. –  Avery Chan Jun 5 '12 at 8:25
Use apt-get download apache2.2-common and dpkg -x apache2.2-common*.deb fs to extract files to a directory called fs. You can then check it yourself. (this is at least the case with Oneiric and Precise) –  Lekensteyn Jun 5 '12 at 8:51

In my case, by restarting the machine the error went away (I had just installed apache2) and I was able to issue the command sudo /etc/init.d/apache2 restart and have apache2 restart.

share|improve this answer

Got this when I tried sudo /usr/sbin/apache2 -k restart.
Actually apache2 in /usr/sbin was link to shared library '/lib/apache2/mpm-worker/apache2'
Instead sudo /etc/init.d/apache2 restart should be used as mentioned.

share|improve this answer

When I ran apache2 -M I got the same error. Found this solution:

groupadd sshusers

I have no idea why this fixed it, but it did.

share|improve this answer

Maybe it's about KEEPENV="PATH APACHE_RUN_USER APACHE_RUN_GROUP" in /etc/conf.d/apache2 (on Gentoo)

KEEPENV will tell apache to keep those environment variables alive while starting

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.