PHP FILE RESTART APACHE

Hi,

Not sure where to put this thread that is why I am posting here.

Here’s my problem, i want to restart apache service using a php file or via Web. I know I can restart it using SSH but I am wondering how to restart the apache service using PHP or via WEB

I am using the very simple command below and it is not working
<?php
shell_exec (‘service apache2 restart’);
?>

Thanks in advance

NAME=“openSUSE Leap”
VERSION=“42.3”

Well, when you SSH into the system, I presume you log in and then have your preferred way to execute the service command as a root owned process.

As the Apache processes, including the PHP spring-offs, do not run as a root process, the command will not function.

I assume that should not surprise you, because it would be a security hole measured in miles wide and deep. :wink:

Look at WebMin:

https://doxfer.webmin.com/Webmin/Apache_Webserver