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

I have several folder that I use for uploading file from PHP. I have change the group permission of this folder to www-data ( a group that apache2 also shares ). but somehow I am still not able to upload a file to it. I think I miss some small thing, but I'm not really sure what it is. Any idea?

Below is my folder configuration :

ubuntu@myip:~/tweb/Server/myserver/assets$ ls -l 
total 112

drwxrwsr-x 2 ubuntu www-data  4096 Aug 23 10:02 attachment
drwxrwxr-x 2 ubuntu www-data  4096 Aug 23 10:02 photo
drwxrwsr-x 2 ubuntu www-data 16384 Aug 23 10:02 logo

Below is the screenshot of the apache instance.

ubuntu@myip:~/tweb/Server/myserver/assets$ ps aux | grep apache

www-data  2324  0.1  3.8 285548 23036 ?        S    03:32   0:00 /usr/sbin/apache2 -k start
www-data  2326  0.0  3.9 287104 23888 ?        S    03:32   0:00 /usr/sbin/apache2 -k start
www-data  2327  0.1  3.8 285560 23152 ?        S    03:32   0:00 /usr/sbin/apache2 -k start
www-data  2328  0.1  3.8 285544 23140 ?        S    03:32   0:00 /usr/sbin/apache2 -k start
www-data  2329  0.1  3.8 285828 23276 ?        S    03:32   0:00 /usr/sbin/apache2 -k start
www-data  2332  0.0  1.6 276284 10076 ?        S    03:32   0:00 /usr/sbin/apache2 -k start
www-data  2333  0.0  3.3 282852 20520 ?        S    03:32   0:00 /usr/sbin/apache2 -k start
www-data  2334  0.0  1.6 276284 10076 ?        S    03:32   0:00 /usr/sbin/apache2 -k start
www-data  2336  0.0  1.6 276276  9984 ?        S    03:32   0:00 /usr/sbin/apache2 -k start
www-data  2714  0.0  1.4 275624  8504 ?        S    03:40   0:00 /usr/sbin/apache2 -k start
ubuntu    2718  0.0  0.1   8128   660 pts/0    S+   03:41   0:00 grep --color=auto apache
root     22942  0.0  2.6 275592 15904 ?        Ss   Aug23   0:14 /usr/sbin/apache2 -k start

When I checked to which group www-data is belong to, it seems that the user is belong to www-data group.

groups www-data
www-data : www-data
share|improve this question
    
Have you checked web server & PHP logs? –  Drew Khoury Aug 26 '13 at 10:11
    
yes. already check the username who run the php script and it also said as "www-data". Using : $current_user = trim(shell_exec('whoami')); –  Rudy Aug 26 '13 at 11:08
    
What errors did the logs have in them? –  Drew Khoury Aug 26 '13 at 12:08
    
The PHP code works correctly, so it opens a form with multipart file etc. right? –  fsoppelsa Aug 26 '13 at 16:02

1 Answer 1

In order to write to a new file in a directory, the user needs write permission on the directory. It also needs scan ('x') permission on every one of that directory's parent directories.

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.