Run command as other user


Recommended Posts

Hey guys. I'm doing a little "restore" feature for my website in PHP, basically it has to extract a copy of itself from a tar.gz file, which I am doing like thus,

$command = "tar xvzf backup/Core.tar.gz";

exec($command);

and it all works fine, cept I then don't have permission to edit the files afterwards as they belong to 'www-data'. I could run it using sudo, but it doesn't seem to give me an option to enter a password. (I'm not really bothered about hard coding the password)

Is there an easy way to solve this? I spose once I've actually finished with the site I won't need to edit it anymore so it won't be a problem, but during testing its going to be a pain.

Thanks! :)

Link to comment
Share on other sites

No because www-data owns the files. The easiest thing to do, though, would be to add yourself to the www-data group and give the files rw permission for group.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.