Support » Fixing WordPress » Permissions/problems uploading images

  • The problem:-

    When I try to upload images from wordpress, I get an error such as:
    Unable to create directory /var/www/vhosts/ 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.


    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/


    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.



Viewing 4 replies - 1 through 4 (of 4 total)
  • 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!

    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

    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 🙂

    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


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Permissions/problems uploading images’ is closed to new replies.