Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a php file which is trying to read and write xml files on my Ubuntu server, however the problem is that it does not have permission to do this (permission denied error).

I have tried the following chown www-data read_write.php with no luck

What is the proper way to change permission for this file?

more info

-rwxrwxr-x 1 www-data www-data 14092 Sep 6 12:33 read_write.php

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Maybe you are a little confused...

The "d" character in front of your string means only that this is a directory, not a file. You should look at your XML's permissions instead!

share|improve this answer
    
xml has the right permission drwxrwxr-x 6 www-data www-data 4096 Sep 6 12:38 xml but I still get a permission denied error. –  mk_89 Sep 6 '12 at 12:20
1  
@mk_89 A file cannot have permissions drwxrwxr-x, since the d implies a directory... –  Mihai Todor Sep 6 '12 at 12:21
1  
xml is a directory, not a file. You need to look at your XML's files, not directory. –  Andrea Giardini Sep 6 '12 at 12:22
    
Ok I see what you guys mean, the actual file has the permission -rw-r--r-- –  mk_89 Sep 6 '12 at 12:23
    
chmod g+wr $your_xml_file - Assuming that it's owner is also www-data:www-data –  Andrea Giardini Sep 6 '12 at 12:25

Just check where is it writing the files, which directory and either do chmod 777 /path/to/xml/directory or chown it to the username and group which either apache is running as or in case you're using fcgi or similar(like php-fpm) chown it to the username and group which the php fcgi/php-fpm processes are running as.

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.