WordPress Plugin upgrade failed error finally solved

WordPress LogoI have had a many WordPress blogs over the years installed on shared hosting and have had little problem installing and managing them. I used a great auto upgrade plugin before automatic upgrades came to WordPress in version 2.7 (I think). But even with automatic upgrading of versions and plugins, having many blogs, it still took some manageing to make sure all my blogs were up-to-date and secure. So I planned for the what I saw as the Holy Grail of a WordPressMU (now Multisite option) install on a virtual server to combine all (or at least most) of the blogs I manage onto one server therefore one time upgrade of versions and plugins.

For reasons better none to me at the time and partially explained on this post I started from LAMP configured Ubuntu 10.04 server install (my server of choice). After some initial issues problems were solved the WordPress 3.0 with Multi Site install, with the domain mapping plugin appeared to be all configured correctly. Not till slightly later did I find that I could not upgrade the plugins automatically (one of the prime reason for having the WordPressMU configuration). The error message I got was as below but basically it appeared that there was an access/permission issue.

Enabling Maintenance mode…
Updating Plugin Akismet (1/1)

Downloading update from http://downloads.wordpress.org/plugin/akismet.2.4.0.zip…
Unpacking the update…
Installing the latest version…
Removing the old version of the plugin…
Plugin upgrade failed.

An error occured while updating Akismet: Could not remove the old plugin..

After much googling I was still left scratching my head, although there were many forum posts on a similar subject they, for the most part, would go the same way:

  1. WP user complains of not being able to upgrade plugins
  2. Many other WP users chime in with similar issues
  3. A helpful soul says its not a problem just set every file and folder (and the kitchen sink) to have permissions of 777 (read, write and execute access for everybody and his passing dog)
  4. Then a very sensible WP user advises this is incredibly fool-hardy and insecure and you should never do this
  5. Finally the forum posts end without any real answer

I did temporarily set all folders to 777 to see if this would solve the problem and it had no effect for me what so ever. What did initially appear to be the issue was that my virtual server did not have FTP access as nearly all shared hosting has. But by following this very useful blog post from LornaJane I knew this was not the issue and completely agreed that I did not want to have an FTP server (another vulnerability) if I did not need to.

I was getting closer to my answer in the post and comments from LornaJane with the command to make the apache user be able write to the WordPress directory as follows:

chown -R apache:apache

But wait, as the my default Ubuntu server does not use the user/group apache but instead uses www-data the command I finally used via ssh on my remote server was:

chown -R www-data:www-data /var/www

And as if by magic my auto upgrades worked. Hopefully this may help someone else as well.

37 thoughts on “WordPress Plugin upgrade failed error finally solved”

  1. Ahh amazing! I was having the same problem so I chmodded the update folder to 777 which worked, but then when it needed to delete the files it didn’t work. Works very nicely now though. Thanks (:

  2. Ok I have no idea where to go to put in this:

    chown -R www-data:www-data /var/www

    What file or where does that need to go?

    Thanks

  3. Hi Mike
    The command needs to be put into the terminal. Linux servers, which host 99+% of all WordPress installs, are administered using the terminal often referred to as the command line (looks similar to a Windows DOS screen). If you have a remote hosted server you would usually connect via SSH. Not all hosts give SSH and some you need to request SSH access. I appreciate this itself may sound very technical.

    Some useful links:
    Terminal – https://help.ubuntu.com/community/UsingTheTerminal
    SSH (ignoring the addresses as you would need your own from your host) http://compudoc.princeton.edu/compudocwiki/index.php/HowTos:Connect_to_login_servers_via_ssh

  4. Philip, you’ve beaten the issue I have been struggling with for a few days. I had figured out a way around it by giving elevated permissions to particular files/folders that would remain permanent. I knew this was incorrect as my personal host uses the default perms. Everything works great on my host. I absolutely knew it had to do with either users or group perms. It turns out that I was right but not the first to figure it out.

    Fortunately, I take meticulous notes of everything I do. This way, I can recreate, or undo, what I have done. I have since returned all permissions to their defaults and have chown’d the web directory to the ‘apache’ user (running CentOS). I feel much more secure with your wonderful write-up.

    Thank you,

    Corey…

  5. Our website is hosted by a Windows Server (not Apache) and we have been getting the cannot remove old plugin when trying to use the automatic plugin upgrade since several versions ago of WordPress. Like you I keep reading about it in the support forums and researching it on the Web and do not find any definitive solution. I already tried the permissions fix and that didn’t do it. Do you think your advice could translate to an IIS host somehow?

  6. Hi Sharani
    Many thanks for your comment and apologies as I initially missed your comment as it got stuck in my spam filter. I do not have a lot of experience of IIS but I would think a lot of the issues could relate any to any server as file permissions and FTP access is generic across web servers. Where I could not help is with a solution as the commands I used were specifically for Linux. I really hope you have found a solution to your problem especially as you posted some time ago.
    Kind regards
    Phil

  7. There must be several root causes of this. I messed with permissions and ftp settings but the only thing that was working for me was to delete the plugin directory and start over. Finally I tried deactivating the plugin first before upgrading. Now upgrades for all plugins work 100% of the time. Give that a try if others workarounds aren’t working for you.

  8. Can someone help me with steps up to this point? How exactly to get to the right place in terminal?

    1. Hi. Whereabouts are you stuck? The WordPress Forums can be very useful of you have a specific issue – http://wordpress.org/support/. I was following notes on the codex – http://codex.wordpress.org/Migrating_Multiple_Blogs_into_WordPress_3.0_Multisite to het here.

  9. OH my god, I have no Idea what I’m doing. A whole bunch of words I do not understand all for a cause I don’t believe in. Completely out of context from my knowledge base.
    I sure hope this will be beneficial.

    1. It should read as Follows:
      the command to make the apache user be able write to the WordPress directory as follows:chown -R apache:apacheBut wait, as the my default Ubuntu server does not use the user/group apache but instead uses www-data the command I finally used via ssh on my remote server was:chown -R www-data:www-data /var/www

        1. Hi Dana. Sorry it did not help. If you find a solution feel free to post back if you think it would help anyone else looking for a similar solution.

  10. Awesome! Everyone seems to suggest that FTP is the correct answer, but I’m running my own server and can physically load files to it without FTP! Your answer worked flawlessly!! Thanks!

  11. Funny. I transfered ny multi-site install from vps.net to Linode so time ago and had a problem updating. Googled the problem and found my own post! Doh!

    Worked first time:

    chown -R www-data:www-data /var/www

  12. Hi,
    Very nice tutorial. I found it as I was having an issue while deleting a plugin. It was on my local development (wamp server) and the reason was that a file (some-font.ttf) was open by httpd.exe.

    Anyway, I would like to add something and that is, if you are using Linux Server (which I use heavily on all my production sites) with VPS or dedicated access, it is better to use suPHP to execute PHP scripts as the owner of the script, instead of the user with which apache2 is running. This way, you can always have the right permission and if you are like me, who likes to separate each of the sites with different linux users, then one bad script from a site can not affect another.

  13. I cannot understand why this does not help me. I’m working with a pre-installed centOs. Everything installed fine via installatron but I cannot update any plugins. I can’t get rid of the message , could not remove old plugin…

  14. Hi!
    Sorry if this is a silly question, I do not quite understand about this but I’m having the same problem… What should I do if my site is hosted in Godaddy.com? Should I ask for help to the technical service or I can do it myself from my hosting account? I would appreciate your help!!

  15. It worked for me too, after hours and hours of Googling to find this thread:

    Ownership of /var/www must be www-data:www-data. I am thankful but Judas how subtle!

    If I were project director for WordPress.org (or Codex or whoever), I would insist a WP installation CHECKOUT routine/plugin/app/whatever be written which scans an installation, checking for proper or acceptable file ownership and permissions! Please inform me why that can’t be done.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>