[Tool/Web/Other] [PHP] How to start / stop Linux Server
#1

Hi.
Im tryin 2 make a Control Panel for SAMP with PHP. I use Linux.

I got this functions:
Код:
	function StopServer(){
		echo shell_exec('pkill -f samp02Xsvr');
		echo "<br />";
	}
	function StartServer(){
		echo shell_exec('/opt/samp/start.sh &');
		echo "<br />";
	}
But it just doesnt work. No error. Nothin.

I'm usin lampp with php5. Do i need to change something in the configuration of lampp or php? If yes, what?

or is my code just wrong?


P.s. Startin' server manual with start.sh works.
Reply
#2

Take off the echo, echo means that it will output that rather than executing it.
Reply
#3

Sounds strange, cause shell_exec gives back the output from that function. And the function gives back output also without echo. i'll try also if i know that it can't be because of that
Reply
#4

The function itself may also echo stuff back (such as the passed command) but you must remove the echo.

In addition, you must call the StartServer / StopServer function for it to actually execute that code.
Reply
#5

Lol I know, im not stupid.

I just wrote the functions. of course i call em. Thats not the whole Script

http://php.net/shell_exec

the function doesnt echo sth itsel. it returns the output.
Reply
#6

Quote:
Originally Posted by d123
Hi.
Im tryin 2 make a Control Panel for SAMP with PHP. I use Linux.

I got this functions:
Код:
	function StopServer(){
		echo shell_exec('pkill -f samp02Xsvr');
		echo "<br />";
	}
	function StartServer(){
		echo shell_exec('/opt/samp/start.sh &');
		echo "<br />";
	}
But it just doesnt work. No error. Nothin.

I'm usin lampp with php5. Do i need to change something in the configuration of lampp or php? If yes, what?

or is my code just wrong?


P.s. Startin' server manual with start.sh works.
Do not ever run the servers under apache, this means it's insecure, especially when doing shared hosting (multiple users on 1 server).
Always run every server under it's own shell.

Quote:
Originally Posted by KingJ
Take off the echo, echo means that it will output that rather than executing it.
No, echo will of course execute it too, what else does it have to output?
Reply
#7

I'm the only one who uses the Apache.
On the Server just is 1 Samp Server, 1 CSS Server and Apache.
And the Apache was just installed for the control panel for SAMP.

Hm But how to fix the problem, that it doesn't work?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)