Reloading Apache with PHP

Hello! Help please need to restart Apache using php script!

Answer 1, authority 100%

Apache for your php script will be the parent process, so crashing it, although possible, is not necessary.

It’s better to create some file from php that will serve as a flag: you need to reload apache. A separate script will run regularly, for example, with crondor at, and look for the presence of such a file: if there is, it will overload the server.

Make a separate suid script for this, in which write (one of the options, depends on the version of Apache, operating system, etc.):

apachectl -k restart
service apache restart
service apache2 restart
/etc/init.d/apache2 restart
/etc/rc.d/init.d/httpd restart

Or better yet, make a passwordless key and run via ssh:

ssh -i key-file [email protected] service apache2 restart

Actually, you can run Apache without root, but then you won’t be able to bind it to port 80; which, in turn, can be overcome with a redirect to iptables.