restart/reload apache services via php [duplicate]
Possible Duplicate:
Can PHP restart Apache?
Hello,
I want to restart/reload httpd services via the web browser, is it possible if so how.
Thanks Jean
(I'm assuming linux or something *nixish)
Create a shell script which restarts the server
#!/bin/bash
/etc/init.d/apache2 restart
Make it executeable and set the SUID bit
chmod +xs /path/to/script.sh
And from PHP simply
exec("/path/to/script.sh")
Problem solved.
Edit: Actually this wont work, because the suid shell script wont start the other shell script with suid.
You could add a line to your /etc/sudoers files which allows the script to be executed without password and then
sudo /path/to/script.sh
That should work.
精彩评论