Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian User (http://www.linux-archive.org/debian-user/)
-   -   Apache2 restart from PHP ? (http://www.linux-archive.org/debian-user/185211-apache2-restart-php.html)

Leszek 10-30-2008 09:14 PM

Apache2 restart from PHP ?
 
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.

Jeff Dickison 10-30-2008 09:51 PM

Apache2 restart from PHP ?
 
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 debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


All times are GMT. The time now is 12:10 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.