Basically, I cannot restart/stop my Apache server. I receive the following error:

aditya@aditya-desktop:/usr/sbin$ sudo ./apache2 -k restart
apache2: bad user name ${APACHE_RUN_USER}

Any idea as to what is causing this error and how to resolve it?

link|improve this question
Belongs to Server Fault. – RaYell Aug 27 '09 at 6:38
what operating system? – theotherreceive Aug 27 '09 at 7:34
feedback

migrated from stackoverflow.com Aug 27 '09 at 6:46

This question came from our site for professional and enthusiast programmers.

3 Answers

You don't say what system you're running, but,

% egrep '(User|Group)' /etc/apache2/apache2.conf 
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

This is the standard ubuntu setup. The user/group that apache runs at aren't set in the config file, but in /etc/apache2/envvars, which is sourced by the init script.

You should use the init script to restart apache, /etc/init.d/apache2 restart or if for some reason you can't, set your own envrionment variables and use apachectl.

link|improve this answer
+1 would also be my answer.. – rkthkr Aug 27 '09 at 9:30
feedback

First of all I'd try to use the apache2ctl command for the job.

sudo apache2ctl restart

EDIT after petre comment:

I think you are not using any wrapper, but trying to start the daemon running the apache2 bin directly, thus obviously not having any ENV variable being set

link|improve this answer
Good tip. All the arguments of apache2 are also available via apache2ctl, but the latter has the correct environment set. I use this wrapper script for the useful commands: apache2ctl -S or apache2ctl -M – Martijn Heemels Feb 28 '10 at 16:38
feedback

an error in the wrapper script - either user apache2ctl as instructed below, or search the script for the APACHE_RUN_USER variable and see what's wrong

link|improve this answer
1  
I think he is nothing using any wrapper, but tries to start the daemon directly running the apache2 bin directly, thus obviously not having any env been set – AlberT Aug 27 '09 at 7:11
feedback

Your Answer

 
or
required, but never shown