On Thu, 30 Oct 2008, Leszek wrote:

> Helo,
>
> 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
finish.

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.

Jeff


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to