How to run a process on debian 7 via PHP?

<?php $output = shell_exec('/root/testsrv ./samp03svr &'); ?> 

- does not work. Everything happens on one virtual server, the .php file is in / var / www

  • Are you sure that the user under which php works is available directory / root. Usually it is available only to the root and in fact it should be so - Mike
  • @Mike, no. I didn't even think about it. Is it possible to give access to the user under which php works? How to do it? Is it safe or is it better to implement it differently? - ES.
  • it is better to implement it in a different way - put the files where they will be available for reading to the user on whose behalf your script is executed (most likely it is www-data ). for example, in the same /var/www/какой/нибудь/каталог - aleksandr barakin
  • @Mike, for some reason this option does not work for me. I tried all the options described in the topic. - ES.

1 answer 1

Solution: A custom was created. sh script on / off / restart of the server using screen

 cd $path screen -dmS $screenName ./samp03svr & echo "Ok" 

and .php script:

 shell_exec('bash /var/www/CP/server.sh start'); 

Posted by: Disinterpreter