我需要執行一些命令在我的web服務器上用php配置了apache。爲什麼php命令`exec(「service apache2 restart」);`在ubuntu上不工作?
exec("service apache2 restart", $output);
print_r($output);
輸出:
Array (
[0] => * Restarting web server apache2
[1] => Action 'start' failed.
[2] => The Apache error log may have more information.
[3] => ...fail!
)
我的猜測是,那是因爲在我的Ubuntu PHP的權限! 你有什麼建議?
如果你通過網絡像'http:// localhost/restartserver.php'運行它,它將以'www-data'用戶身份運行。缺省情況下,www-data用戶無權重新啓動Web服務器。 – joar
你試圖做的通常是一個壞主意。 – PeeHaa