tags:

views:

50

answers:

3

How can I run this from PHP?

sudo /etc/init.d/apache2 restart
+1  A: 

I don't think that's a good idea.

Also, have a look to the following discussions:

http://stackoverflow.com/questions/425717/can-php-restart-apache

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

Roberto Aloi
A: 

Just use the system() or exec() function without the sudo in the command, and run the php script as root.

nandu
A: 

You can use the exec command. http://ch.php.net/manual/en/function.exec.php

If you want to use sudo, just add the user Apache is running under (usually www) in the /etc/sudoers file.

svens