开发者

restart/reload apache services via php [duplicate]

This question already has answers here: 开发者_如何学编程 Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜