I am getting this error trying to restart Apache, does anyone know how to fix this? Thanks,
9 Answers
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 - 3The first block can probably keep referencing the environment variables; the crucial step is defining them in
/etc/apache2/envvars!Ingo Karkat– Ingo Karkat2013-07-30 09:23:02 +00:00Commented Jul 30, 2013 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-datais the fix that worked for me.Daniel Chapman– Daniel Chapman2014-01-06 00:51:32 +00:00Commented Jan 6, 2014 at 0:51
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.
- /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– Henry2014-09-23 05:30:46 +00:00Commented Sep 23, 2014 at 5:30
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.
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.
- Probably an upgrade that did not affect configuration.
/etc/init.d/apache2is supposed to load this variable. You can manually extract the conffile from a deb file and replace it.Lekensteyn– Lekensteyn2012-06-05 08:17:24 +00:00Commented Jun 5, 2012 at 8:17 - Really? What does your
/etc/apach2/apache2.confsay 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.Son of the Wai-Pan– Son of the Wai-Pan2012-06-05 08:25:15 +00:00Commented Jun 5, 2012 at 8:25 - Use
apt-get download apache2.2-commonanddpkg -x apache2.2-common*.deb fsto extract files to a directory calledfs. You can then check it yourself. (this is at least the case with Oneiric and Precise)Lekensteyn– Lekensteyn2012-06-05 08:51:22 +00:00Commented Jun 5, 2012 at 8:51 - This worked for meTesto Testini– Testo Testini2016-03-19 08:55:03 +00:00Commented Mar 19, 2016 at 8:55
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.
I got the same error when trying to run apache2 -M also.
I ended up just sourcing the envars file like this:
. /etc/apache2/envvars That set the environment variable properly since running apache2 outside of the standard init script.
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.
manually edit /etc/group and add www-data there then start apache
add www-data:x:1012:www-data at end of file and save it Ctrl-X Yes {enter} (1011 was last num in my group file)
start apache sudo service apache2 start
it worked in my case
I had the sane problem and checked apache2ctl status and it said I needed to configure www-browser or adjust apache_lynx
My shell told me to install lynx, so I did, and that solved it for me.
sudo apt-get install lynx
sudo apache2? Tryapache2ctlinstead. See this answer: askubuntu.com/a/147065/56343