LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-11-2009, 08:01 PM   #1
haleymiska
LQ Newbie
 
Registered: Nov 2009
Posts: 1

Rep: Reputation: 0
Need help restarting linux servers using PHP


I am trying to develop a server administration page so that I can restart httpd, named, proftpd, mysql, and mail servers from my webpage using php. I started with httpd when I enter the following command from a linux command line, works just fine.

service restart httpd

But when I try and use the following code in my php page

PHP Code:
<?php
$results 
exec('service restart httpd');

echo 
$results;
?>
It fails every time. Some basic commands work, like listing file contents of directorys and such, but not restarting httpd, named, or proftpd.

Please help!
 
Old 11-11-2009, 11:45 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
Which distribution are the servers running? I have only ever known the "service" command to be present on RedHat-based systems.

Furthermore, this would also boil down to an issue of permissions; I highly doubt that the user that all PHP code is interpreted by, is root.

For an easy workaround (although frighteningly insecure), configure "sudo" to allow the user that Apache and PHP run as to use "sudo" without requiring a password.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to do compiling php in web servers chnlinux Linux - Newbie 1 01-26-2008 06:03 AM
PHP in application servers! subalan Linux - Software 1 07-17-2005 03:53 AM
PHP and APACHE servers.. configuration question eech55 *BSD 6 10-20-2004 02:40 PM
How to setup MySQL and PHP servers in different partitions? manofwax Linux - Networking 4 08-18-2004 10:17 AM
Restarting PHP? XxAndyxX Linux - General 8 09-10-2003 01:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration