Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

test.sh's path is /var/www/proj/test.sh, and project.php is inside /var/www/ and my test.sh uses and creates some .txt files.

when i execute test.sh through terminal it works fine, but when I run project.php by

http://localhost/project.php

it fails, the permissions on the txt files also changed, so I have to manually change the permissions of the txt file, even to run through terminal again.

Errors:

rm: remove write-protected regular empty file `/var/www/project/result/List.txt'?  
project/test.sh: line 8: /var/www/project/result/List.txt: Permission denied

So, how can I permanently give write access to /var/www/*

share|improve this question
    
Is your project.php file calling the test.sh? Or what is the relationship between these files? –  Ale Apr 21 '13 at 20:44
    
yeah...project.php calls test.sh whenever the page is refreshed –  pali Apr 21 '13 at 20:47

1 Answer 1

To give write access to /var/www you need to give write access to the user who runs the web server. On Ubuntu for example this can generally be done with:

chown www-data /var/www
chmod u+w /var/www

(to set www-data, being the user running the web server, as owner of /var/www and giving write access to the directory to its owner -- in case he doesn't already have). Depending on your server's configuration, in some cases this might not work (e.g., blocked by a SELinux or AppArmor policy).

However, for security reasons it is not advisable to do this. In the worst case (given a bug in one of the scripts running on the web server), an external attacker might write arbitrary data to /var/www, either putting any contents on your web server, or scripts that he can then execute...

Depending on your application, you might give access to the web server to another (dedicated) directory, and retrieve the files from that directory when you need them in a PHP script.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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