Link to home
Start Free TrialLog in
Avatar of xuzhaogang
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',$output,$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.'',$output,$return); and i cannot get it done and there is no error message shown in my log file.

please kindly advise on the above
ASKER CERTIFIED SOLUTION
Avatar of Robin Uijt
Robin Uijt
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xuzhaogang
xuzhaogang

ASKER

how stupid i am ... forgot the wildcard, yeh it works, thank you, robinu.

but only one small drawback. i found if i don't attach any parameters now, it won't run.

ray
And if you create 2 entries? One without parameters and one with them?