0

I have a bash cgi script called by apache which should move one file in /var/www/html to another in the same directory. I've set up the relevant permissions with selinux (e.g. chcon to httpd_sys_content_t) and I've changed the read/write permissions of the files/dirs and yet it still returns the following in the httpd error logs:

mv: cannot move /var/www/html/file.txt to /var/www/html/file2.text: Permission denied

Any ideas? There's nothing relevant in the audit log either...

Edit:

ls -l on /var/www/html/ shows

-rwxrwxrwx. 1 apache apache  157 May 16 15:50 file.txt

ls -l on /var/www/ shows

drwxr-xr-x. 9 root root  4096 May 17 12:28 html
  • 1
    Can you ls -l /var/www/html/ and show the permissions for this folder? – Nathan C May 17 '13 at 11:26
  • Yep, have just included some extra info... – David Wadge May 17 '13 at 11:32
  • Ah, I needed to change the ownership of /var/www/html from root to apache. Thanks for the ls tip-off Nathan :] – David Wadge May 17 '13 at 11:37
  • Try adding id >/tmp/my-id.txt to see with what id the script is running. The html-directory may only written by root. – ott-- May 17 '13 at 11:37
2

The file permissions for /var/www/html do not allow the apache user to manipulate the directory containing the file. You will need to allow apache write access to the /var/www/html directory.

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.