Sep 8

WordPress (Update Fail)

Tags:

———————————————————————
– OVERVIEW / THOUGHT PROCESS –
———————————————————————

Sometimes, during the smallest of routines, you can come across something that can take hours to figure out!  Fortunately, if you’ve been through the same situation in the past, you can come up with the solution within seconds and go along your way.

This writing is for just that.  If you’re coming across this post, you have more than likely searched something about an update error in WordPress and are looking to figure out how to fix it.

———————————————————————
– Troubleshooting –
———————————————————————

Almost all of the update errors that I’ve run across in WordPress are due to permissions being set incorrectly.  In this particular case, I was using a theme called ‘Eclipse’ and had just created a new domain name and VirtualHost for a website.  After completing all of the essential steps for hosting a new website, my last step was to download and activate the theme that I wanted to use.

I could have used the theme installer if I had configured vsftpd as shown here, however for this install, I chose to download it to my computer and then secure copy (scp -r) the files to my server.  When I started up WordPress and clicked the update button for the Eclipse theme, here’s what I saw:

 

Theme Update Fail

Theme Update Fail

 

# I’ve mentioned before that the first thing that comes to mind when I get an update fail is that the permissions are not set correctly.  This case was no different.  Here’s how I figured that out…

$ cd /var/www/html
$ ls -al wp-content
drwxrwxr-x  6 root apache  4096 Mar  1 17:49 wp-content

# The folder wp-content is the default container in WordPress for holding all of your themes, plugins, and updates.  As such, in order to add something to it, WordPress needs to be able to talk to it.  The output that you’re seeing here shows the permissions (drwxrwxr-x), the owner (root), the group (apache), the size (4096), the date (obvious), and the file or directory (wp-content).  Since WordPress runs through the Apache (httpd) service, the group permissions should be apache… which it is.

$ cd /var/www/html/wp-content
$ ls -al themes
drwxrwxr-x 13 root apache 4096 Mar 1 04:20 themes

# Since the wp-content directory has the correct permissions, let’s go check out the files and directories within. When we look at the permissions for the theme that I uploaded, we see that the owner is root and the group is root. That’s because when I secure copied to the server, I did it as root. After I transferred the files, I should have changed the permissions… so let’s do that now.

$ cd /var/www/html/wp-content/themes
$ ls -al eclipse
drwxrwx–x  8 root   root   4096 Feb 23 03:48 eclipse

———————————————————————
– SOLUTION –
———————————————————————

$ sudo chgrp -R apache eclipse

$ ls -al elipse
drwxrwx–x  8 root   apache 4096 Feb 23 03:48 eclipse

# And now that the permissions are correct, the error goes away and we are now able to update those files.

 

Theme Update Success

Theme Update Success

———————————————————————
– FINAL THOUGHTS –
———————————————————————

Permissions can reek havoc on your every day operations, but they are absolutely essential. Knowing what to set and how to set it can ensure your server’s safety from bots and/or malicious hackers. Knowing that I’ve messed up my permissions in the past, I constantly audit my files and folders to verify they are set correctly. There are ways to automate this process as well, and perhaps I’ll write about that in the future. But for now, when you make changes to your system, don’t be in a hurry to finish. Take your time and verify you did it correctly. If you don’t have time to do it right the first time, how can you time to do it right the second time?

 

—————————————–

Always remember… WHAT IF AND WHY NOT?!?