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 setup a local Apache2, with PHP and mysql. I wrote a maven build script to deploy my page on that local server. All that is working fine except for one thing:

When I instruct maven to clean up the page, means deleting all files, it runs in an permission problem, because maven must not delete Files and Directories created by php.

I have created a group called »web«. »Me« and »www-data« are both members of that group. After all the files are installed, means copied to the right location, maven runs two little commands: chown -R me:web www-dir and chmod -R 777 www-dir, and everything works fine.

Running the Website makes the PHP create files and Directories with this permissons: drwxr-xr-x 2 www-data www-data and maven (or me) are not allowed to delete those files. Trying to run chmod and chown gives the same permission error.

How can I fix that without using the magic »sudo-power«?

Greetings philipp

share|improve this question
    
I think you should be member of www-data group and have drwxrwxr-x permissions on www-dir. The problem will be solved. –  val0x00ff Oct 3 '13 at 7:55
    
I added myself to »www-data«, run: »chown -R me:www-data www-dir« but it still throws an error when trying to delete… –  philipp Oct 3 '13 at 8:16
    
Apache will reset permissions and the owner:group to www-data:www-data where the group has no -w- write permissions. So if www-dir dir has drwxr-xr-x www-data:www-data permissions, then you won't be able to write or delete files since the group has no write permissions. The group has only read + execute permissions. –  val0x00ff Oct 3 '13 at 8:50
    
Your are absolutely right. The permissions are reseted exactly as you say and consequently I cannot delete the files. But how can I work around that? –  philipp Oct 3 '13 at 9:20
    
You can use umask to set the default permissions on the directory tree. umask instructs the kernel to remove bits that will not be set. So umask 002 www-dir will set www-dir to drwxrwxr-x permissions. Hope it helps –  val0x00ff Oct 3 '13 at 10:30

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.