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
1  
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
1  
do a source envvars & then run your command. –  user160453 May 21 '13 at 1:15

7 Answers 7

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:

APACHE_RUN_USER=www-data
APACHE_RUN_GROUP=www-data
share|improve this answer
3  
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:

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

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

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.

share|improve this answer
1  
Can you please explain how and why? –  Whaaaaaat Sep 23 at 1:17
    
/etc/apache2/envvars simply 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. –  Henry Sep 23 at 5:30
    
Add that to your answer, not as a comment. Thanks! –  Whaaaaaat Sep 23 at 6:04

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

 
discard

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.