executing a shell script from a php file

2019-08-04 08:38发布

问题:

i have a php file from which i need to call a shell script which i am doing as follows:

$out = exec("/root/.mozilla/firefox/score.sh 2>&1");
echo $out;

when i execute this code in opera its giving Permission denied. I have given permission to all directory and the script also.

is the problem because of that .mozilla file?? how to solve?? also tried with shell_exec().. not working

回答1:

Have you given the web server user write/execute permissions?:

For example (assuming your web server user is apache belonging to group apache):

sudo chown apache:apache /root/.mozilla/firefox/score.sh
sudo chmod -R 744 /root/.mozilla/firefox/score.sh


回答2:

Ensure that the webuser has permission to access all directories leading up to /root/.mozilla/firefox/. Ideally, you'd move this script someplace else than root's homedir.



标签: php shell