Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As Marc B said, you need root privs to be able to restart Apache. The best way to handle this, IMHO, is to give the user that Apache runs under access to restart Apache via <a href="http://en.wikipedia.org/wiki/Sudo">the <code>sudo</code> command</a>.</p> <p>You'll want to edit your <code>/etc/sudoers</code> file and add lines similar to the following:</p> <pre><code>Cmnd_Alias RESTART_APACHE = /sbin/service apache2 restart www-data ALL=NOPASSWD: RESTART_APACHE </code></pre> <p>You may need <code>nobody</code> instead of <code>www-data</code>, it depends on the user which Apache runs under. On Debian, Apache typically runs under user <code>www-data</code>, whereas under Red Hat, often Apache runs under user <code>nobody</code>. Also, the <code>/sbin/service apache2 restart</code> may need to be <code>/sbin/service apache restart</code> or maybe <code>/sbin/service httpd restart</code>. All depends on your system's configuration.</p> <p>Once that's done, in PHP you can use the code:</p> <pre><code>exec('/sbin/service apache2 restart'); </code></pre> <p>(Obviously changing that if the command to restart Apache differs on your server.)</p> <p><strong>Please note:</strong> <em>this could very well be considered a security risk!</em> If you do this, you fully trust the <code>sudo</code> binary, the <code>service</code> binary, and your system to obey the rules and not let an Apache/PHP process get a root shell. I highly recommend asking on <a href="http://serverfault.com">http://serverfault.com</a> for the implications of what you're doing here.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload