LinuxQuestions.org
Review your favorite Linux distribution.
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 01-15-2009, 07:44 AM   #1
Tomek58
LQ Newbie
 
Registered: Nov 2008
Posts: 11

Rep: Reputation: 0
Start/Stop and Restart server by PHP


Hello!
I would like write panel with start/stop/restart my server.

I start my server in console this command:

Quote:
screen -A -m -d -S hlds ./hlds_run1 -game cstrike -nomaster +exec server.cfg
And i write: ps x

Quote:
vz138:/# ps x
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 init [2]
1692 ? Ss 0:00 SCREEN -A -m -d -S hlds ./hlds_run1 -game cstrike -no
1693 pts/1 Ss+ 0:00 /bin/sh ./hlds_run1 -game cstrike -nomaster +exec ser
1702 pts/1 S+ 18:26 ./hlds_i686 -game cstrike -nomaster +exec server.cfg
7727 ? Rs 0:00 vzctl: pts/2
7728 pts/2 Ss 0:00 -bash
7732 pts/2 R+ 0:00 ps x
It's OK. I wrote script SHELL: start.sh

Quote:
#!/bin/sh
screen -A -m -d -S hlds ./hlds_run3 -game cstrike -nomaster +exec server.cfg
And script: start.php

PHP Code:
<?PHP
exec
("sh /var/www/cs1/start.sh");
?>
But server isn't start. Why?
 
Old 01-15-2009, 07:55 AM   #2
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
Because PHP runs as user apache or httpd and your script or cs server runs with different user.

You need to run apache as root, but thats a very very bad idea, or cs server which the same user rights as php is running.
 
Old 01-15-2009, 08:16 AM   #3
Tomek58
LQ Newbie
 
Registered: Nov 2008
Posts: 11

Original Poster
Rep: Reputation: 0
I have lighttpd. So i change in lighttpd.conf:

Quote:
server.username = "www-data" >>>> server.username = "root"
server.groupname = "www-data" >>>> server.groupname = "root"
??

Now LIGHTTPD isn't start:

Quote:
vz138:/# /etc/init.d/lighttpd start
Starting web server: lighttpd2009-01-15 15:13:59: (server.c.706) I will not set uid to 0
 
Old 01-15-2009, 09:26 AM   #4
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
Seems like lighttpd is build to not allowed to run the web server with root user, which is a super good idea. Try to run the lighttpd and cs server with a normal user, like "joe" ... you get my point, and make sure that the rights for the cs server belong to joe... because I suppose that server can run also as a normal user not just root.

Last edited by robertjinx; 01-15-2009 at 09:27 AM.
 
Old 01-15-2009, 09:47 AM   #5
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by Tomek58 View Post
I have lighttpd. So i change in lighttpd.conf:



??

Now LIGHTTPD isn't start:
The log told you exactly why it wouldn't start- It refuses to set it's id to root (which is a very good thing.) A better answer is to setup the cs server to run as the same user as the webserver (www-data).
 
  


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
VSFTPD Not responding to restart/stop/start commands even in root! phoenix09 Linux - Software 7 09-05-2005 11:28 PM
how can i start, stop or restart Paxmaster Slackware 3 11-27-2004 01:31 PM
how to stop/start/restart iptables? plan9 Linux - Newbie 8 08-06-2004 04:40 PM
Is it possible to start stop and restart a linux service from a webpage? psychodreams Linux - Newbie 3 04-27-2004 01:24 PM
Start Stop Restart Services Sifvion Slackware 6 09-14-2002 03:13 AM

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

All times are GMT -5. The time now is 01:04 AM.

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