Portal Home > Knowledgebase > Articles Database > Web Interface to Restart a Service
Web Interface to Restart a Service
Posted by The Universes, 12-16-2008, 11:31 PM |
Web Interface to Restart a Service
Is there an easy way to make a web interface for stopping, starting, and restarting services like httpd, mail, dns, etc?
Edit:
I know you could just install Webmin, but I'd prefer to have my own script just for this purpose.
__________________The Universes - Server/VPS Management and PHP/MySQL Application Development
|
Posted by bager, 12-16-2008, 11:37 PM |
with php use the exec and system functions to run shell commands.
|
Posted by The Universes, 12-16-2008, 11:46 PM |
Short of running Apache or Lighttpd as root, that won't work. And I was understand it, its not possible to use sudo from exec().
__________________The Universes - Server/VPS Management and PHP/MySQL Application Development
|
Posted by cygnusd, 12-17-2008, 09:13 AM |
I'd recommend supervisord (http://www.supervisord.org).
|
Posted by izwan00, 12-17-2008, 09:33 AM |
exec function should work. But the server must give privilege to use them
|
Posted by juangake, 12-17-2008, 07:33 PM |
You may find useful this PHP function:http://php.net/popen
|
Posted by The Universes, 12-17-2008, 09:39 PM |
Thanks for all the suggestions, I've been able to find a way to make this work.
__________________The Universes - Server/VPS Management and PHP/MySQL Application Development
|
Posted by r0kawa, 12-17-2008, 11:33 PM |
Hi The Universes,
Care to share your finding ?
I usually use /etc/sudoers to allow apache to run a PHP file and that PHP will allow to run any root exec application. It's a little dangerous, but I don't find any easier way other than that.
__________________ZenPipe Hosting : Malaysia VPS Hosting
|
Posted by The Universes, 12-18-2008, 12:48 AM |
SSH through PHP:http://php.net/ssh
It basically SSH'es into the machine, checks the status of the service:http://img257.imageshack.us/img257/3680/servicesnc6.gif
And I can issue re/start, stop commands to it as well.
__________________The Universes - Server/VPS Management and PHP/MySQL Application Development
|
Posted by r0kawa, 12-18-2008, 01:13 AM |
Nice, didn't ever heard about this before. You need to install it by pecl though.
pecl install ssh2
__________________ZenPipe Hosting : Malaysia VPS Hosting
|
Posted by The Universes, 12-18-2008, 01:34 AM |
Nope, untar it, "phpize
|
Posted by r0kawa, 12-18-2008, 01:56 AM |
pear install ssh2-beta
Quote:
Rather than using pear install ssh2 to automatically download and install PECL/ssh2, you may download the tarball from PECL. From the root of the unpacked tarball, run: phpize
|
Posted by The Universes, 12-18-2008, 02:28 AM |
Thats exactly how I did it. DL tarbar, compile, and add to php.ini
__________________The Universes - Server/VPS Management and PHP/MySQL Application Development
|
Add to Favourites Print this Article
Also Read
RoR (Views: 499)