WordPress media uploads first day of use

On a new server you may find that you cannot upload images and it fails with an error,

Unable to create directory /var/www/path/to/your/httpdocs/wp-content/uploads/2011/06. Is its parent directory writable by the server?

This is because of permissions in that the apache web server can’t write to the wp-content/uploads folder.

The wp-content/uploads folder is defined by default in WordPress under the Settings -> Media and doesn’t need to change but you have to get the web server to be able to write to this location on the first day of use.

If you are using Filezilla or similar FTP Client you must set the file permissions of  /wp-content to 777 then go into your post again and add the image. This should work now and if you look at the wp-content directory you will see a new uploads directory with the file permissions of 777 and owner and group will be the apache web server. Set the /wp-content back to 755.

You don’t need to do anything else. It will keep working from now on.

Obviously the issue of setting 777 on a directory when we’re usually told to not do this raises alarm bells so is this an issue ? On shared hosting it could be an issue. A malicious user on another account could get Apache to upload content to this directory and then hotlink to this content in SPAM emails or bogus web sites but if this is a server or virtual server that you control all the shared accounts then there is no real problem.

A good shared hosting company should have setup the Apache mod_suexec and suPHP module for the virtual host that you are using on the shared account system and you won’t have access to that.