简体   繁体   English

用php从shell启动sudo

[英]launch sudo from shell with php

如何从PHP运行此程序?

sudo /etc/init.d/apache2 restart

I don't think that's a good idea. 我认为这不是一个好主意。

Also, have a look to the following discussions: 另外,请看以下讨论:

Can PHP restart Apache? PHP可以重启Apache吗?

http://www.linuxforums.org/forum/linux-security/3068-using-php-restart-apache.html http://www.linuxforums.org/forum/linux-security/3068-using-php-restart-apache.html

You can use the exec command. 您可以使用exec命令。 http://ch.php.net/manual/en/function.exec.php http://ch.php.net/manual/zh/function.exec.php

If you want to use sudo, just add the user Apache is running under (usually www) in the /etc/sudoers file. 如果要使用sudo,只需在/ etc / sudoers文件中添加用户Apache正在(通常在www下)运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM