Re: Reboot Linux Service with PHP



theGerm wrote:

Is it possible for me to restart a service with PHP? I need to run
this from a webpage

/sbin/service squid reload

You can run that using PHP's system() function:

<?php system("/sbin/service squid reload"); ?>

However, normally "/sbin/service X" is just a shortcut to running
"/etc/init.d/X" and if you take a look at the permissions for the contents
of the "/etc/init.d/" directory, they'll mostly be only executable by
root. (And the web server doesn't run as root!)

So the initial reaction is to just change the permissions on
"/etc/init.d/squid" to allow non-root users to run it. That won't work
though.

What you'd need to do is use "sudo" to allow whatever user Apache runs
under (normally the user is called "httpd", "apache" or "nobody") to be
able to run "/etc/init.d/squid".

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
.



Relevant Pages

  • Re: Secure Web-Based Administration
    ... You would be best off using webmin, ... Instead of invoking root processes from your web server, ... the web server process leave authenticated requests in a queue. ... Subject: Secure Web-Based Administration ...
    (Focus-Linux)
  • Re: sendmail messages bounce
    ... installed sendmail on a server which I am also using as a web server. ... verification back, which fails, causing the original email to bounce. ... root is configured as an exposed user - please see cf/README. ...
    (comp.mail.sendmail)
  • Re: arrays for slideshow
    ... This *is* a path that is relative to the root of a Web server or ... it is possible that the slideshow script that you are relying on ... The Message-ID header of your posting is invalid; ...
    (comp.lang.javascript)
  • Re: [PHP] Why a script belong to user root and the folder this script create is belonged to user nob
    ... That has absolutely no influence on what user the process *runs* as. ... Apache is typically started as root to allow it to listenon ... itself, it forks, the child process switches its effective user id to ... Cuz if you are running your web server as root, ...
    (php.general)
  • Re: Relative and Absolute Address
    ... reference to the root of the web application and *never* use root relative ... You'll have to dig in and replace all those references with either relative references or some ... I recently began maintenance work on a production web server that is located ...
    (microsoft.public.inetserver.asp.general)