I have a php script with this:

#echo exec('whoami');

$output = shell_exec('bash /usr/local/svn/bash_repo/make-live');
echo "$output";

The make-live script contains this:


cd /var/www-cake

sudo svn checkout file:///usr/local/svn/bash_repo/repo/

echo "Head revision has been pushed to live server"

So the PHP user who is www-data needs to have nopasswd for that script. I am told I need to add:

www-data ALL=NOPASSWD: /usr/local/svn/bash_repo/make-live

To sudoers to allow this. First I run sudo visudo but I have no experience with vi so I try to open it in gedit with export EDITOR=gedit && sudo -E visudo which then just opens a sudoers.tmp file which is empty. I add the line and save it. But it doesn't do save.

So I just try sudo visudo and I add the line right beneath this part:

# User privilege specification
root    ALL=(ALL) ALL
www-data ALL=NOPASSWD: /usr/local/svn/bash_repo/make-live

I closed out sudoers and reopened to verify that it has saved. I even restart apache.

I run the php file and it still doesn't work.

What am I missing?

  • Were you able to solve this? If yes, how? May you please post the answer. I seem to be facing the a similar issue.
    – Shyam K
    Aug 8, 2012 at 12:08

1 Answer 1


Adding your apache user www-data to sudoers and then worse adding a no-password option is a REALLY BAD IDEA. It's a security issue to have the apache user being able to do anything as root and you should avoid it.

What you need to do is change the permissions of /var/www-cake so that www-data can write to it when you run svn checkout without the sudo.

Try this: sudo chown www-data:www-data /var/www-cake

Remove the sudo and try again.

  • I ran the command, I checked the permissions of the www-cake directory to verify that www-data is the owner. I removed "sudo" from the command in the make-live script. I then executing the php script by loading it in my browser. It did not work.
    – JD Isaacks
    Dec 29, 2010 at 21:05
  • The fact that it didn't work is related to your PHP code/configuration, it is expected to work, sudo is not a solution. Dec 29, 2010 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.