Apache2 restart from PHP ?
On Thu, 30 Oct 2008, Leszek wrote:
> I'm using debian etch and try to use exec command from php to restart
> apache2. I wrote a bash script.sh witch contain line like this:
> /etc/init.d/apache2 restart
> and added line
> www-data ALL = (root) NOPASSWD: /var/www/script.sh
> When I do:
> 1. # su www-data
> 2. $ /var/www/script.sh
> apache restarting with no problems, but when I do the same using in php file
> exec("/usr/bin/sudo /var/www/script.sh");
> apache is going down with the message in error.log:
> [notice] caught SIGTERM, shutting down
> What I do wrong ?
> P.S. Sorry for my poor english.
You want to use reload instead of restart in your script. Reload allows
all the current apache processes finish before restarting, where restart
just kills everything and your script really doesn't get a chance to
That being said, doing something like this is very dangerous in this way.
I wouldn't suggest using something like this at all. Its an extremely
easy way to keep your server offline or much worse.
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact firstname.lastname@example.org