ubuntu - running sudo shell script from php
Hi,
I am using Ubuntu Dapper and I want to run a command as root from a php script. I try: <?php $output = shell_exec('sudo -u root -S ls < /home/mitilma/passfile'); echo "<pre>".$output."</pre>"; ?> However, ls command does not work in that case. It works without sudo in php, but with sudo, I cannot see any files listed. What is the problem? How can I solve it? Thanks a lot.. |
Have you setup sudo for the Apache user and to not require a password from that user for that command?
|
You said
"Have you setup sudo for the Apache user and to not require a password from that user for that command?" How can I achieve it? I am new for Linux, and I really need help.. Thanks a lot.. |
As root, run 'visudo' and add something similar to these lines:
Code:
Cmnd_Alias APACHECMDS = /path/to/command/for/apache/user/to/run Code:
Cmnd_Alias APACHECMDS = /path/to/command/for/apache/user/to/run \ |
All times are GMT -5. The time now is 01:43 AM. |