PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Sep 17, 2019 5:04 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Restart service via PHP
PostPosted: Tue Aug 25, 2009 5:47 am 
Offline
Forum Newbie

Joined: Tue Aug 25, 2009 5:44 am
Posts: 1
Hello everyone,

Been bashing my head for the past two days on this... I'm nowhere near experienced to figure out how to do this from scratch so I've been searching for the past two days for this..

How can I restart a service (specially the squid service) via a PHP webpage? I know there are a lot of complications with permissions and commands - I'm not too fussed on the permission/security front, as this is a private project and won't be entering the real world :)

I've tried exec(service squid restart) but the error goes down to permissions there..

Any ideas?

Thanks!

lieb39


Top
 Profile  
 
PostPosted: Fri Sep 11, 2009 3:51 am 
Offline
Forum Regular
User avatar

Joined: Mon Aug 29, 2005 6:26 am
Posts: 509
Location: Pearls City
add the webserver user group to root group and execute the code


Top
 Profile  
 
PostPosted: Fri Sep 11, 2009 4:23 am 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria
You'd better use sudo instead of changing any permissions (or membership).

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Mon Oct 26, 2009 4:56 pm 
Offline
Forum Newbie

Joined: Sat Sep 05, 2009 9:19 am
Posts: 4
what do you guys thinking about SSH ?
will it work (connect via PHP to SSH and send the command) ?


Top
 Profile  
 
PostPosted: Mon Oct 26, 2009 5:21 pm 
Offline
DevNet Master
User avatar

Joined: Fri Jan 18, 2008 1:36 am
Posts: 3549
Location: Israel, ME
Why would you need to connect to anything? PHP already runs on the server. You just need the proper permissions / credentials.


Top
 Profile  
 
PostPosted: Wed Oct 28, 2009 1:50 am 
Offline
Forum Newbie

Joined: Wed Oct 28, 2009 1:41 am
Posts: 2
visudo and add webuser.

sudo allows a permitted user to execute a command as the superuser or another user, as specified in the
sudoers file. The real and effective uid and gid are set to match those of the target user as specified
in the passwd file (the group vector is also initialized when the target user is not root). By default,
sudo requires that users authenticate themselves with a password (NOTE: by default this is the user’s
password, not the root password). Once a user has been authenticated, a timestamp is updated and the
user may then use sudo without a password for a short period of time (5 minutes unless overridden in
sudoers).

man visudo
man sudo


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group