Question

I need to exec command from php to write into my vhosts.conf. I have one add_vhost.sh file :

cat /home/www/test/conf/vhosts.conf >> /etc/httpd/conf.d/vhosts.conf

this is php script:

 exec($path_to_add_vhost_sh_file, $output);

i want to set no password requirement for peter user to exec this file, so i did next thing in my /etc/sudoers

peter ALL=(ALL)NOPASSWD:/home/www/test/conf/add_vhost.sh but its still not working, even in console. fedora 15

Was it helpful?

Solution

If your webserver runs as the www-data user user:

www-data ALL=(ALL:ALL) NOPASSWD: /path/to/your/script

If not, replace www-data by your web server's user name.

In php don't miss to prepend your command line with sudo:

exec('sudo /path/to/your/script');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top