This post will help solve a number of problems I have had and seen many other people have with WordPress blogs such as problems uploading images, installing plugins and upgrading your blog automatically.
Firstly and most importantly and the reason I am writing this blog is because I have seen a lot of really bad advise around.
The top of the bad advice list is where people suggest you change the access permissions of our WordPress blog files to 777 (e.g. read and write for anyone). I find this absolutely absurd! No one should ever need to do that for anything, this is bad for many reasons not to mention security issues that is could cause but, I digress, lets get onto business…
The solution is pretty simple and will solve anyone’s problem that has root (or sudo) access to their server. This also assumes you will be using a terminal and ssh. If anyone needs help in another way please post your questions / comment and I’ll see what I can do to help.
OK, to start of you will need to ssh onto your server and browse to the parent directory of your WordPress blog and type the following:
sudo chown -R www-data:www-data MyWPblog
Obviously you will need to replace the MyWPblog with the folder name of your WordPress blog. If you logged in as root, tat tat, you can exclude sudo from the command.
Explanation of above command
chown is the command to change the owner and group of the files you specify, the -R makes the chown command recursive so it is applied to all files and folder in the directory tree under the specified folder.
For the next part of the command I have put www-data, this is the system account (on my machine) for the Apache web server. This may be different for you but from my experience this is the usually account. If you re not sure you can look in your password file by using the following command:
It should be fairly obvious, look for webadmin if you cannot find www-data. It also wont do any harm to change the ownership of the files once or twice and then testing your blog if you not sure which one to use.
So, why change the ownership of the files? The answer is pretty straight forward. The Apache server runs your blog and therefore the account that Apache uses is what your blog uses. Changing the file ownership to that of your Apache server account enables the site to do whatever it needs to install and update, create and copy files and folders WITHOUT changing the access permissions to 777!
Hope this helps. Please comment if I have not been clear about something or you need further help / advice that I have not mentioned here.