Results 1 to 6 of 6

Thread: Apache permissions

  1. #1
    Join Date
    Dec 2008
    Location
    United Kingdom
    Beans
    47
    Distro
    Ubuntu

    Apache permissions

    When i upload files to my www directory using a user i created myself the files do not show up (the apache logs show permission denied). I managed to fix it by using chmod -R 775 but i'm having to type that each time i add new files.

    How can i allow people to access the files without having to type this chmod command each time?

  2. #2
    James78's Avatar
    James78 is offline Extra Foam Sugar Free Ubuntu
    Join Date
    Sep 2008
    Beans
    Hidden!

    Re: Apache permissions

    775 is good, but all the files are supposed to be owned by the Apache user, www-data. This is why you have to add additional permissions.

    For example, your username is myuser, now, myuser makes some files in /var/www, and these files have user and group read/write for example, but no world read/write. Apache can't access it because the files are owned by myuser, so you fixed the problem by making it word readable. Created files will always be apache readable/writable if they're owned by www-data. This was a really quick explanation just slopped together, I may not be exact exact on some super super fine details, but the whole idea still gets through excellently.

  3. #3
    Join Date
    Dec 2008
    Location
    United Kingdom
    Beans
    47
    Distro
    Ubuntu

    Re: Apache permissions

    I understand, i think. So could i possibly add myuser to www-data group? Would that be possible, would that fix it?

  4. #4
    Join Date
    Dec 2010
    Beans
    573
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Apache permissions

    Not really. When a user creates a file it is owned by their UID and primary GID, just putting your account if the www-data group will not cause your account to create files as the www-data group unless you make it your primary group.

    To fix it you could create a script or alias that runs the command:
    Code:
    sudo find /var/www/ -user `whoami` -exec chown www-data:www-data "{}" \;

  5. #5
    Join Date
    Dec 2008
    Location
    United Kingdom
    Beans
    47
    Distro
    Ubuntu

    Re: Apache permissions

    Could i login to www-data and upload the files that way? I'm just looking for a quick and simple fix. I just want to be able to upload the files over ftp and that would be all.

  6. #6
    James78's Avatar
    James78 is offline Extra Foam Sugar Free Ubuntu
    Join Date
    Sep 2008
    Beans
    Hidden!

    Re: Apache permissions

    If you're using ProFTPD, you could use mod_exec to execute a command after files are uploaded, to change them to www-data.

    If you want to know what I do. Is this.

    I have a user, which my files in /home/user/public_html. When I create files and whatnot there, they're owned by user:user of course, with read/write user, and read group (default permissions basically). Now, Apache can access my files perfectly fine. You may be wondering how in the world did I do that since they're not world readable!

    The solution is fairly simple. You see, since I have group readable, Apache could access my files if it has access to my group.. Or...
    Code:
    sudo adduser www-data myusergroupname
    More information about my FTP solution here.
    http://stackoverflow.com/questions/9...-added-via-ftp

    Quote Originally Posted by ash369 View Post
    Could i login to www-data and upload the files that way? I'm just looking for a quick and simple fix. I just want to be able to upload the files over ftp and that would be all.
    Not really no.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •