WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Permissions/problems uploading images (5 posts)

  1. Mark Rowatt Anderson
    Member
    Posted 6 years ago #

    The problem:-

    When I try to upload images from wordpress, I get an error such as:
    Unable to create directory /var/www/vhosts/site.com/httpdocs/wp-content/uploads/2008/01. Is its parent directory writable by the server?

    The setup:-

    I'm running WP2.3 on Linux. It's my box (so I have root access), and I'm using Plesk to manage web sites (which has a few quirks but is mostly OK). I'm using PHP 5.04 and safemode is off.

    Analysis:-

    The uploads directory (ie wp-content/uploads) is mode 777. When wordpress tries to upload a file, it successfully creates the first directory of the date hierarchy (ie '2008'). This directory is also mode 777, user/group is apache.

    However, wordpress is subsequently unable to create the next down directory (ie '01'). If I manually change the owner of the '2008' directory to the user of the v-host which wordpress is running under, and try the upload again, WordPress successfully creates the '01' directory (mode 777, user/grp apache) and now fails to upload the file with error:
    The uploaded file could not be moved to /var/www/vhosts/site.com/httpdocs/wp-content/uploads/2008/01

    Question:-

    What's going on? WordPress is creating directories with the user and group of the apache server (as expected), AND those directories are mode 777, but then it can't create directories or files underneath. (yet I can create a directory there myself on the command line with any user, so mode is definitely 777).

    Is there some apache or PHP setting that might be causing this?

    Any pointers gratefully received.

    Thanks,

    mark.

  2. Mark Rowatt Anderson
    Member
    Posted 6 years ago #

    Sorted it myself... silly mistake. For the benefit of anyone else searching on this:-

    Make sure php safe_mode is off! It was off by default on my server, but I hadn't noticed that it had been turned on for this virtual host.

    To check, create a file containing:

    <?php phpinfo(); ?>

    and run it from your web space. Search for "safe_mode" and check that safe_mode is 'off' for the middle of the columns (ie the one headed local).

    The uploads directory itself should be mode 775 or 777 (ie chmod 775 or chmod 777 [path to uploads directory]). If 775 works for you that's more secure than 777.

    If your host won't allow you to have safe_mode off, then you are back to where I was before... maybe someone else will have suggestions. A reasonable workaround is to turn off the "Organize my uploads into month- and year-based folders" option (under options/misc) and set the permissions of the upload directory as above.

    Hope this helps someone!

  3. sitecreations
    Member
    Posted 6 years ago #

    First of all, it's terrific when someone takes the time to come back and post the resolution. markauk, it is appreciated.

    With Plesk, and the solution above please note that in many cases safe-mode changes (e.g. on Plesk) will not take effect until the Apache is restarted.

    This means that your safe mode change request may be queued and happen up to 2-3 hours later. If you need things faster, ask your web host to restart Apache. It's easy for them to do.

    Scott Clark
    http://www.websiteadvice.com

  4. 3stripe
    Member
    Posted 6 years ago #

    Anyone using Plesk 8 should have an option to set safe mode on/off buried in the settings tab of your domain:

    Domains -> Setup -> Services

    Worked for me straight away without having to restart :)

  5. brent3721
    Member
    Posted 5 years ago #

    Fixed it. I went to the wordpress settings in the admin area then to the miscellaneous section and saw the full path to the uploads directory on our shared server (which is crazy long) changing it to a relative path wp-content/uploads was all we had to do to fix the problem. Hope this helps someone

    brent
    @
    mimoymima.com

Topic Closed

This topic has been closed to new replies.

About this Topic