Most of you know that installing WordPress is a pretty easy and straight forward job, and if you don’t know it already just try it out once or twice and you’ll see how easy it is. But if you’ve been around the block you’ll also know that different hosting environments and situations can throw some different scenarios at you.
Not too long ago I came across a problem that I haven’t seen before. The situation was installing WordPress in a hosting environment with a Plesk Control Panel. Although this situation could arise in multiple other environments, I just hadn’t encountered it because I normally prefer to stick to VPS and VDS hosting without a control panel, and I really stay away from purely shared hosting like it’s the plague.
After installing WordPress any time I tried to upload media (with the setting to organize by date) into the WordPress system I would get the error:
Unable to create directory /var/www/vhosts/[mydomain]/httpdocs/wp-content/uploads/2009/11. Is its parent directory writable by the server?
The part that threw me off was that I had created the uploads directory, I gave the directory 777 permissions so that Apache could create files and folders beneath it, and I actually found that the installation would create the “2009″ directory, but nothing any further. If I went ahead and created the “11″ directory and gave it write permissions then it could write uploads, but once the next month came around same problem again.
To top it all off, I first came across this problem in front of a client that I was teaching some hosting tricks. So now I was just looking like an idiot.
Turns out the problem was related to Safe Mode. My own bad habits persisted when normally setting up domains so I would turn Safe Mode off in my own VPS hosting, but when teaching the “correct” way I recommended leaving Safe Mode on. Well if your scripts are owned by your domain user, and then naturally running under the Apache User, then Safe Mode won’t create objects underneath a path that has mixed ownership.
It will allow the first directory to be created “2009″, but then the next won’t be allowed. So the easy solution is to turn off Safe Mode.
Some people probably won’t think this is the best option. The same people don’t like to set public folders to 777. But if you are on VPS hosting with a Plesk CP inside your container and it’s just your container you are good to go. No one else has access to your system but you in the first place.
Of course if you are on or providing shared hosting for many customers, this might not be ideal. With Shared Hosting you will be giving access to those folders to other customers in the same shared environment. It would be more ideal to just change the ownership of all the WordPress files to “Apache:Apache” or whatever user:group that apache is running as. Then you can leave Safe Mode on, and folder permissions to be writable only need 755. Keep in mind that this only works if you are the provider, if you are just hosting on a shared system you won’t have the ability to do this.