The MU forums have moved to WordPress.org

Apache + permissions (19 posts)

  1. Person
    Member
    Posted 14 years ago #

    We've installed WordPress MU on our server, and it has all gone smoothly with one exception: everytime it creates a new file or folder (such as blogs.dir), the owner is Apache rather myself. My user isn't exactly the administrator of the server, so this locks me out from viewing or changing any of the created files or folders. This isn't my forte, so what can I do to change the default ownership of the created files to my own user rather than Apache? Or what other way can/should I go about this?

  2. Ovidiu
    Member
    Posted 14 years ago #

    if you change ownership back to your user, apache can't change those files anymore... depends on what you want/need...
    But I guess you'll have to ask your host to change them for you

  3. Person
    Member
    Posted 14 years ago #

    Well how else can I gain access to the files/folders without changing ownership?

  4. andrea_r
    Moderator
    Posted 14 years ago #

    He means the new folders WP/MU is creating for uploads - they kinda need to be in use by the web account owner.

    Crap, I had this issue once. My memory bank retrieval system is fuzzy this morning.

  5. Ovidiu
    Member
    Posted 14 years ago #

    well, you could try and set your user as the owner and the group of the webserver as the owning group, using Debian it would be kinda chown -R youruser:www-data blogs.dir/ BUT still, the newly created folders and files will still be owned by apache...

    you might try a host that offers PHP running as suPhp or fastcgi+suexec then the webserver runs as your user, would solve the problem, though suPhp is a little slower than mod_php

    thats all I can contribute, maybe someone else can give more info.

  6. tdjcbe
    Member
    Posted 14 years ago #

    If this is a CPanel box sitting on a *NIX OS, renaming the folder will usually reset the ownership to the account holder. This was a long time bug but I believe it may have been fixed recently. Direct Admin boxes retain ownership though.

    You should also be able to grep the wpmu code for the mkdir line and assign both ownership and permissions there. Haven't tried it but I know we had to do it on one install way back when to get around not being able to set permissions correctly.

  7. Person
    Member
    Posted 14 years ago #

    Well we managed to get the permissions to view and edit files that apache creates, but it still leaves a problem when it comes to user file uploads. When someone tries to upload something, the folder # is created, but the file isn't uploaded as the following error is returned:

    Unable to create directory /wp-content/blogs.dir/5/files/. Is its parent directory writable by the server?

    Manually creating # folder, but not the files folder results in the following:

    The uploaded file could not be moved to the upload folder.

    If I manually create the folders #/files/, then the user can upload without a problem (as the folder's ownership is no longer Apache's). I tried looking for a solution, but the only thing returned was stuff like setting permissions to 777 or recursively changing ownership... This isn't ideal, since you still have to do this for every new user added.

    Another thing I noted was that it's impossible to change the upload path for an individual blog, no matter if I modify the settings under the edit blog options.

  8. Person
    Member
    Posted 14 years ago #

    Hmm, well a non-ideal solution would be to modify wp-settings.php (lines 290-297) and change the upload path(s) there so that all files are lumped into one single folder. It seems that WPMU recognizes which blog uploaded what file, and will automatically append a number if there already exists a file with that name. Though what's the purpose of the if statements if the upload paths are never defined elsewhere? If anyone has an alternative solution, please let me know.

  9. andrea_r
    Moderator
    Posted 14 years ago #

    Put /blogs.dir/ to 777. What happens?

  10. Person
    Member
    Posted 14 years ago #

    No different than before (I've tried it).

  11. Person
    Member
    Posted 14 years ago #

    Sorry for the bump, but I've got a new question in regards to the former. When a user uploads a file and links it from/adds it to their post, it'll link to '.../files/filename.ext'. If I'm correct, then the file is actually being linked to '.../wp-contents/blogs.dir/blogid/files/filename.ext'. The problem with that however is that the files are stored in a different folder, which results in a 404 page. The only thing I can think of is that this is caused by the .htaccess file :

    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

    What exactly would I need to change to get it to point to (a) different location(s)? Or how could I fix this?

  12. andrea_r
    Moderator
    Posted 14 years ago #

    Well, that's how MU is supposed to work. It rewrites the actual location from the blog.dir user folder, to something that looks more WP-like.

    Are you getting the 404 on files that you *know* are on the server?

  13. Person
    Member
    Posted 14 years ago #

    Yeah I know the file is on the server. I even put the file under /blog.dir/blogid/files/ to see if it would make a difference, but no dice.

  14. andrea_r
    Moderator
    Posted 14 years ago #

    It has to be under /blog.dir/blogid/files/year/month/day/.

    I think. that's where they wind up when uploaded anyway.

  15. Person
    Member
    Posted 14 years ago #

    No, WPMU out of the box doesn't categorize them by date. This might have been the case in previous versions, but I haven't seen it once create any year/month/day folders. It even states that it doesn't categorize them by date when you go to edit the blog options. But anyhow, this is off topic from my question. (adding the date option will just return me to my initial problem, since the folders will belong solely to apache and no user will be able to upload anything whatsoever)

  16. Person
    Member
    Posted 14 years ago #

    Hmm well I managed to fix this problem myself. I had to modify wpmu-functions.php (misc functions) to correspond with my own changes, and then added a new rewrite rule within the htaccess file so that it would point towards the correct file & folder.

  17. eborg9
    Member
    Posted 13 years ago #

    Wow ! I can't believe that I read through this whole post hoping that there was a solution, only to find out that you got it fixed and didn't tell us how.
    Bummer.

    Modified wpmu-functions.php how?
    Added what kind of rewrite rule to htaccess ? Specifically.

  18. eborg9
    Member
    Posted 13 years ago #

    I actually found a solution. I just recently moved servers, so what I was experiencing was a permissions issue.

    I had to CMOD the content/blogs.dir directory and all of its contents to 777.
    That fixed the issue site wide.

  19. tdjcbe
    Member
    Posted 13 years ago #

    Um, that's not really a solution but more of a work around. You may want to check the ownership of the files and set them to either the username of the hosting account or the user the webserver runs under.

    Chances are the ownership of the files is set to a four digit number like 1000. The files are still owned by the original owner on the old server and since that user doesn't exist on the new server, the new server is trying to place them with a non existent user.

About this Topic