xuzhaogang
asked on
How to configure sudoers to allow PHP execute with parameters
hi,
i am trying to execute a php (/var/www/server.php) in system folder from a php (/var/www/html/client.php) in web folder.
what i have done is:
in the client.php, i put exec('sudo /usr/bin/php -f /var/www/server.php',$outp ut,$return );
in the server.php, i just put echo "OK";
in the /etc/sudoers, i put nobody ALL=(ALL) NOPASSWD: /usr/bin/php -f /var/www/server.php
it works fine like above. but i want to pass some parameters to the server.php, so i edit my client.php like exec('sudo /usr/bin/php -f /var/www/server.php '.$src_file_path.' '.$dest_file_path.'',$outp ut,$return ); and i cannot get it done and there is no error message shown in my log file.
please kindly advise on the above
i am trying to execute a php (/var/www/server.php) in system folder from a php (/var/www/html/client.php)
what i have done is:
in the client.php, i put exec('sudo /usr/bin/php -f /var/www/server.php',$outp
in the server.php, i just put echo "OK";
in the /etc/sudoers, i put nobody ALL=(ALL) NOPASSWD: /usr/bin/php -f /var/www/server.php
it works fine like above. but i want to pass some parameters to the server.php, so i edit my client.php like exec('sudo /usr/bin/php -f /var/www/server.php '.$src_file_path.' '.$dest_file_path.'',$outp
please kindly advise on the above
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And if you create 2 entries? One without parameters and one with them?
ASKER
but only one small drawback. i found if i don't attach any parameters now, it won't run.
ray