Hello guys 
Here's my situation: I am operating a Linux Debian virtual root server, on which i have several applications running, including a TS3 Server and an Apache2 / PHP5 installation.
Lately I have experienced, that my TS3 Server crashed occasionally (like once a month - there is literally no information in the logs...). Anyway, since I am the only one with access to the VRS and my friends are using the TS3 Server, it would be cool, if they had an easy way to start up the server should it crash and I am not around.
So I thought it shouldn't be too hard to write a PHP script and a shell script, which would do exactly that - start the TS3 server.
My php file test.php, in the directory /var/www/ looks like this:
Furthermore, my shell script ts3.sh (obviously in the directory /var/www/):
When I execute the script from the command line using PuTTY (logged in as root, simply inputting /var/www/ts3.sh) I get
When I access the Webpage (test.php) all I get is "Test", but nothing on the TS3 server.
Both test.php and ts3.sh have the execute (X) permission set. I read somewhere, one has to create command aliases and stuff for the account "www-data", but I didn't really get it, as I have never touched Linux before (Although I do have fair experience with PHP). All the "basic" shell commands like "ls" work perfectly fine using the PHP script, it just seems I can't execute anything outside of the /var/www directory.
Any help would be greatly appreciated - if you need more details please ask
Greetings, Elewyth
PS: I don't seem to find any kind of errors when executing the php script through the browser, also with error_reporting(E_ALL) set - there is no error log file either.
Edit: For anyone reading this thread because he got similar problems, the solution is adding
(replace the directory with the needed one) to your sudoers file (execute visudo), beneath the line that grants all the permissions to root.
Here's my situation: I am operating a Linux Debian virtual root server, on which i have several applications running, including a TS3 Server and an Apache2 / PHP5 installation.
Lately I have experienced, that my TS3 Server crashed occasionally (like once a month - there is literally no information in the logs...). Anyway, since I am the only one with access to the VRS and my friends are using the TS3 Server, it would be cool, if they had an easy way to start up the server should it crash and I am not around.
So I thought it shouldn't be too hard to write a PHP script and a shell script, which would do exactly that - start the TS3 server.
My php file test.php, in the directory /var/www/ looks like this:
PHP:
<?php
$output = shell_exec('/var/www/ts3.sh');
echo "<pre>" . $output . "</pre>";
?>
Furthermore, my shell script ts3.sh (obviously in the directory /var/www/):
Code:
#!/bin/bash
echo "Test"
/usr/local/teamspeak/ts3server_startscript.sh status
When I execute the script from the command line using PuTTY (logged in as root, simply inputting /var/www/ts3.sh) I get
Code:
Test
Server is running
When I access the Webpage (test.php) all I get is "Test", but nothing on the TS3 server.
Both test.php and ts3.sh have the execute (X) permission set. I read somewhere, one has to create command aliases and stuff for the account "www-data", but I didn't really get it, as I have never touched Linux before (Although I do have fair experience with PHP). All the "basic" shell commands like "ls" work perfectly fine using the PHP script, it just seems I can't execute anything outside of the /var/www directory.
Any help would be greatly appreciated - if you need more details please ask
Greetings, Elewyth
PS: I don't seem to find any kind of errors when executing the php script through the browser, also with error_reporting(E_ALL) set - there is no error log file either.
Edit: For anyone reading this thread because he got similar problems, the solution is adding
Code:
www-data ALL=NOPASSWD: /var/www/ts3.sh
Last edited: