I need to execute some commands on my web server with php configured with apache.
exec("service apache2 restart", $output);
print_r($output);
output:
Array (
[0] => * Restarting web server apache2
[1] => Action 'start' failed.
[2] => The Apache error log may have more information.
[3] => ...fail!
)
My guess is it’s because of permissions of php on my ubuntu!
What do you suggest?
You need to run :
check that you have a line like
with your own local IP at the top of the file, then add a line
And last in your PHP file :
(You are trying to restart apache by web, maybe you don’t know webmin interface ? I think there’s betters solutions than this sudo way. It’s not a good thing to authorize www-data to stop, start (…) all the services. Better explain why you’d like to restart apache 😉 )