So i'm looking for a way to start Plex Media Server service using PHP redirect. I basically want to start and stop the server by going to the certain URL. I'm using Apache and here's my code and commands i'm using:
My /var/www/site/index.php:
<?php
$output = shell_exec('/var/www/site/plex.sh');
echo "<h1>Output: " . $output . "</h1>";
?>
/var/www/site/plex.sh
#!/bin/bash
sudo service plexmediaserver start
echo "Done"
After going to my website, i get header "Output: Done" as expected. But Plex process is still inactive (service status). Permissions for site directory and files are set for "www-data" user and plex.sh is executable (chmod +x). Permissions for directory and files are rwxrwxrwx and user running apache is www-data.
Are commands wrong or is it something else?