You are here: Re: Reboot Linux Service with PHP « PHP Programming Language « IT news, forums, messages
Re: Reboot Linux Service with PHP

Posted by Toby A Inkster on 03/29/07 16:34

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!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация