How to Upgrade Wordpress from the Command Line in Two Steps

    Share    


upgrage wordpress from command line How to Upgrade Wordpress from the Command Line in Two Steps

Before upgrading backup your database, then use an FTP program to copy ALL the files in your Wordpress directory to your hard drive. This way you don’t miss any important files, or backup just the files you believe are important, such as wp-config.php., .htaccess, themes directory, database backup file, etc.

Wordpress comes with an automatic upgrade that sometimes hits a snag, causing you to start over, and it is recommended to deactivate all plugins before the upgrade. Not a good experience when you’re pressed for time, and don’t want any blog downtime.

With the directions below you will be able to upgrade Wordpress in only two steps from a command line using either SSH or telnet.

Using the block of commands below you will not need to deactivate, then reactivate any plugins, there will be zero blog downtime, and there are no snags. The commands are setup to delete only the directories and files that will be upgraded, which leaves all of your other files intact. Simply change the username, password, and blog-directory to the appropriate pathway. Take note you will need to add an extra blank line after the last command to send the last carriage return so you won’t have to hit enter.

In the example below the rm -fR will work on Redhat 5, but on Redhat 4 you would need to use rm -rf. Check your operating system syntax to be sure the example below will work as expected. Always backup everything first to prevent a catastrophe.

cd /tmp
wget http://wordpress.org/latest.zip
unzip *.zip

cd wordpress

cd wp-content

cd themes

rm -fR *

cd ..

cd plugins

rm -fR *

cd ..

cd ..

cd ..

su username
password

cd /var/www/blog-directory
rm -fRv wp-admin
rm -fRv wp-includes
rm -fv index.php
rm -fv license.txt
rm -fv readme.html
rm -fv wp-app.php
rm -fv wp-atom.php
rm -fv wp-blog-header.php
rm -fv wp-comments-post.php
rm -fv wp-commentsrss2.php
rm -fv wp-config-sample.php
rm -fv wp-cron.php
rm -fv wp-feed.php
rm -fv wp-links-opml.php
rm -fv wp-load.php
rm -fv wp-login.php
rm -fv wp-mail.php
rm -fv wp-pass.php
rm -fv wp-rdf.php
rm -fv wp-register.php
rm -fv wp-rss2.php
rm -fv wp-rss.php
rm -fv wp-settings.php
rm -fv wp-trackback.php
rm -fv xmlrpc.php
cp -fvr /tmp/wordpress/* .
exit
cd /tmp
rm -fR /tmp/wordpress
rm -f /tmp/*.zip

If everything works as expected you can now upgrade Wordpress in only two steps, copy and paste.

For those that cannot use telnet or SSH, Wordpress has simple upgrade and more detailed upgrade instructions on their site.

We’ll cover upgrading Wordpress via FTP in a different article.

Wordpress has an automated upgrade script, as mentioned above, which only works if you use the FTP port 21. If you use a different port, you’ll need to change it using wp-config.php.

I do not recommend insecure telnet, but I do recommend SSH. A good Secure Shell program is SecureCRT, although it’s not free.


Related posts:


Posted on September 8, 2009 at 5:16 pm(PST)
Tags: | | | | | | |


One Response to “How to Upgrade Wordpress from the Command Line in Two Steps”

  1. I wish I found this post about 10 minutes ago. Upgrade via SSH is sometimes needed when the automatic upgrade fails. I was able to upgrade via SSH though my plugin upgrades return blank pages with no errors. Either way thanks.

Leave a Reply

© Copyright Nerd Grind 2009. All rights reserved.