How to configure apache to create files with correct group owner

I’ve got WP site on a self-hosted server. Any files I create are owned by me/me and any files created by WP are owned by apache/apache. I’ve created a group, wp, that both me and apache are members of and that works ok. But how can I set this up so when either me or apache creates or edits a file or directory that it gets the wp group owner (as well as group write access)?

Thanks for the assistance.

Related posts

Leave a Reply

2 comments

  1. You may as I have found need to change the group that apache runs under. In ubuntu you can do this by editing the /etc/apache2/envvars file.

    The above answer by AlxVallejo is mostly correct but this (Tom’s) is a better answer with regards to setting permissions
    https://serverfault.com/questions/6895/whats-the-best-way-of-handling-permissions-for-apache2s-user-www-data-in-var

    Also I found that even when you do all that, because WordPress is rather dumb on how it checks permissions adding these lines to the end of wp-config.php helps resolve plugin and auto-update hiccups:

    /* Force direct file updating
     - http://www.charleshooper.net/blog/wordpress-auto-upgrade-and-dumb-permissions/
    */
    define('FS_METHOD', 'direct');
    

    See the link for more info.

    Hope that helps.

  2. By default, a new file will inherit the permissions of it’s parent directory.

    You need to enter this on the command line:

    chmod -R apache_group=664 directory_name

    To verify, check directory permissions

    ls -l

    To change the actual owner, you would do

    chgrp -Rv apache_group wp_content

    *R means it’s recursive and v means verbose and will do ls -l for you