The word is already out that WordPress 2.1.1 is severely vulnerable and you have to upgrade to WordPress 2.1.2 to keep your blog safe.
Since the release of 2.1 we have seen two upgrades in little over a month and upgrading WordPress can be a real pain in the neck. It becomes really bad when you’re talking about upgrading more than one blog.
For those who have shell access upgrading WordPress can be a lot less painful and this guide hopes to set you establish just that. I upgraded three installations in less than fifteen minutes. It would have been faster but I am sure I saved a great more time had I to do it the hard way!
Firstly, make sure you backup your installation. There are a lot of guides explaining this, so I won’t go into detail, unless you want me to.
Once, the database is backed up, login to your account via shell and navigate to the folder of your WordPress installation. Mine is installed in public_html itself.
Once in there run the following commands (read the notes at the end first):
-
wget http://wordpress.org/latest.tar.gz
-
tar xfz latest.tar.gz
-
rm -rf ./wp-includes/
-
rm -rf ./wp-admin/
-
cd wordpress/
-
cp -rpf —-reply=yes * ../
-
cd ..
-
rm -rf ./wordpress/
-
rm -f latest.tar.gz
The above commands will fetch the latest WordPress installation and untar it. It then deletes wp-includes and wp-admin and all its subfolders and files. If you have modified any files in there, you will need to make the modifications again.
We then copy the newly downloaded files to your existing WordPress installation.
The untarred files and the downloaded .tar.gz file are deleted.
After running the command above, run the upgrade file in /wp-admin/upgrade.php in your browser.
While this guide will work with just about any WordPress upgrade, I advise you to use it only for minor updates. When making a major upgrade, say from 2.0 to 2.1, it is advisable to delete all the old WordPress files before moving the new ones.
I haven’t touched wp-content and its subfolders above to ensure your existing files, plugins and themes are not effected. Any new files, plugins and themes that come bundled with the new version of WordPress will overwrite the existing ones.
Ohh… and tell me how much time this has saved you.
Note:
- The code above will work only on a Linux / Unix server.
- I’ve been informed that the
--replymay not work/be needed on certain Linux installations. - It also assumes that you are logging in to the shell via your own account. If you login via
root, the permissions will change and you will need to runchown -R username *(change username to the account owner’s username) to correct the permissions. This can cause problems with WP-Cache, so you will need to reinstall the plugin again. - If you are using translations, please backup
wp-includes/languagesbefore running the commands above.
Disclaimer: Make sure you backup your installation. I won’t be held responsible if something goes wrong when you follow this guide.
Liked this article? Stay in touch with us! Don't forget to Stumble It!
Grab the site feed
, subscribe via email or add to your Technorati favs.
Posted by Ajay under Articles, Tips and Tutorials, WordPress
Post Information:
You may also like these posts:
- WordPress 2.3 Dexter is out loose
- WordPress 2.2.3 Upgrade File
- WordPress Bug Fix Release
- Was Hacked, Now I am back
- WordPress Wednesday: Getz WordPress 2.2
71 Responses to “ Upgrading WordPress via Shell ”
Comments:
Have your Say!
Trackbacks & Pingbacks:
-
Pingback from Weblog Tools Collection » Blog Archive » Upgrade WordPress via Shell
March 3rd, 2007 at 7:28 pm[...] Upgrade WordPress via Shell guides you to upgrading your existing WordPress installation to the latest one if you have shell access to your hosting account. And if you haven’t upgraded to 2.1.2 yet, then please do so immediately to ensure that your WordPress 2.1 installation doesn’t get hacked. (No Ratings Yet) Loading … [...]
-
Pingback from Actualizando Wordpress vía Shell en Crónica de una vida
March 3rd, 2007 at 11:53 pm[...] de actualizar a Wordpress 2.1.2 ya que lo recomiendan urgentemente y lo he realizado siguiendo un artículo que he encontrado en internet para hacerlo vía [...]
-
Pingback from Upgrading Wordpress via the Shell-- Place of Stuff
March 4th, 2007 at 12:10 am[...] Following on from today’s security upgrade announcement, I have come across a blog post which explains how to upgrade Wordpress using the shell. [...]
-
Pingback from mattdavis.biz » Blog Archive » WordPress 2.1.1 Compromised
March 4th, 2007 at 2:03 am[...] I came across this script that greatly simplifies the upgrade. Considering I usually do the entire upgrade by hand, that [...]
-
Pingback from Fast Way To Upgrade WordPress Via Shell » Interweb World
March 4th, 2007 at 2:28 am[...] I was very pleased to stumble across Ajay’s neat instructions on how to upgrade WordPress via SSH shell. I’ve done a couple of upgrades now and neither have taken any more than 5 minutes [...]
-
Pingback from Multi-faceted Abnormal /blog » Typical
March 4th, 2007 at 3:19 am[...] just upgraded, they discovered a grave security risk. Good thing I just found instructions to upgrade using shell access, which made the whole process a matter of [...]
-
Pingback from ThemePress » Weblog Tools Collection: Upgrade WordPress via Shell
March 4th, 2007 at 12:31 pm[...] Upgrade WordPress via Shell guides you to upgrading your existing WordPress installation to the latest one if you have shell access to your hosting account. [...]
-
Pingback from Upgrading WordPress via Shell on UNIX and Linux servers - Carols Vault
March 4th, 2007 at 7:02 pm[...] friend Ajay, wrote an article on Techtites on how to upgrade your WordPress via Shell on Unix or Linux [...]
-
Pingback from La Bitácora del Tigre · Urgente: actualización de WordPress a la versión 2.1.2
March 4th, 2007 at 8:15 pm[...] de referencia en el universo WordPress, como Geek Ramblings, Holy Shmoly!, Lorelle on WordPress y Techtites, han hecho hincapié en su necesidad. Entre nosotros, Blogpocket, La brújula verde, Diario a bordo [...]
-
Pingback from La Bitácora del Tigre · 300
March 4th, 2007 at 8:21 pm[...] de referencia en el universo WordPress, como Geek Ramblings, Holy Shmoly!, Lorelle on WordPress y Techtites. Entre nosotros, Blogpocket, La brújula verde, Diario a bordo y Mangas Verdes machacan, en general [...]
-
Pingback from DIY - How to upgrade Wordpress FAST using Shell | zedomax.com - blog about DIYs and Review on reviews of gadgets and technologies...
March 5th, 2007 at 3:50 am[...] via techtites diy, fast upgrade, fast wordpress upgrade, shell access, Web, wordpress, wp upgrade, Zedomaxdiy, fast upgrade, fast wordpress upgrade, shell access, Web, wordpress, wp upgrade, Zedomax [...]
-
Pingback from SF.net PT 2: Setting up a demo site « SunBurntKamel
March 5th, 2007 at 8:48 am[...] thing, which takes a while, or you can just upload the *.tar.gz file and unzip it on the server. Techtite just posted an explanation of this, although there are a few differences I’ll explain in a [...]
-
Pingback from WeblogToolsCollection DE » Blog Archive
March 5th, 2007 at 11:43 am[...] Upgrade WordPress via Shell führt einen durch den Ablauf eines Upgrades einer vorhandenen WordPress Installation, wenn man auf seinen Account Zugriff via Shell hat. Und wenn ihr noch nicht auf 2.1.2 aktualisiert habt, holt das bitte sofort nach, um sicher zu stellen, dass eure WordPress 2.1 Installation nicht kompromittiert wird. (No Ratings Yet) Loading … [...]
-
Pingback from Ellis Web » Upgrading Wordpress through Shell
March 5th, 2007 at 1:32 pm[...] is why I am very thankful that I saw this: Upgrading Wordpress via Shell. I am a Windows guy without so much *nix scripting experience. Still if this could work, it would [...]
-
Pingback from Izikistan » Blog Archive » Upgrading WordPress using rsync
March 7th, 2007 at 5:50 am[...] the recent flurry of WordPress upgrades I started looking for an easier way to upgrade. This post at techites.com was a good start, but this comment on the post, using rsync, sounded much easier. Here’s the [...]
-
Pingback from Faster Multiple Wordpress Upgrades via Shell Access
March 8th, 2007 at 12:41 am[...] If you run one wordpress blog, then probably you can follow the full upgrade instructions and finish in about 15-30 minutes. But what if you have multiple wordpress blogs to upgrade? Ajay points to a fast way to upgrade wordpress via Shell. [...]
-
Pingback from Easier upgrade of WordPress « TechnologyTales.com
March 9th, 2007 at 5:10 am[...] Posted by John on March 4th, 2007 Here’s a post on upgrading your WordPress installation if you have a Linux or other UNIX web server and command line or shell access to it: Upgrading WordPress via the Shell. [...]
-
Pingback from Extralogical · WP, Shell and Me
March 9th, 2007 at 11:22 pm[...] Upgrading WordPress via Shell [...]
-
Pingback from Scribble Designs » Fast Way To Upgrade WordPress Via Shell
March 26th, 2007 at 2:56 am[...] I was very pleased to stumble across Ajay’s neat instructions on how to upgrade WordPress via SSH shell. I’ve done a couple of upgrades now and neither have taken any more than 5 minutes [...]
-
Pingback from WordPress Bug Fix Release » Techtites
April 3rd, 2007 at 2:33 pm[...] If you're irritated about the frequent upgrades, save time by following my tutorial to upgrade via shell. Liked this article? Stay in touch with us! Don’t forget to Stumble It! Grab the site [...]
-
Pingback from Weblog Tools Collection » Blog Archive » APAD: Instant Upgrade
April 7th, 2007 at 8:47 am[...] have become rather frequent, with a release almost every month. While several users like me prefer using shell to speed up upgrades, most normal users are stuck with the normal lengthy routine of doing so, [...]
-
Pingback from WeblogToolsCollection Español » Blog Archive » APAD: Instant Upgrade
April 9th, 2007 at 8:36 pm[...] algo mas frecuente, con una publicación casi cada mes. Mientras algunos usuarios como yo prefieren usar shell para acelerar las actualizaciones, la mayoría de los usuarios normales quedan atorados con la [...]
-
Pingback from Top methods for keeping your Wordpress installation and Wordpress plugins up-to-date | fiLi’s tech
May 21st, 2007 at 6:14 pm[...] maybe Techtites’ [...]
-
Pingback from Fast Wordpress Upgrade with Instant Upgrade · Learning On Demand
June 9th, 2007 at 6:05 am[...] Upgrading WordPress via Shell [...]
-
Pingback from wordpress.vek-safe.ru » Архив блога » Автоматическое обновление Wordpress
July 18th, 2007 at 6:28 pm[...] пользователи могут воспользоваться еще одним решением, демонстрирующим автоматическое обновление Wordpress [...]
-
Pingback from WordPress 2.2.3 Upgrade File » Techtites
September 10th, 2007 at 10:44 am[...] could update your installation via a few shell commands. However, if you don't have shell access then you'll need to upgrade the usual [...]
-
Pingback from TechnologyTales.com | Easier upgrade of WordPress
September 27th, 2007 at 4:49 am[...] Here’s a post on upgrading your WordPress installation if you have a Linux or other UNIX web server and command line or shell access to it: Upgrading WordPress via the Shell. [...]
-
Pingback from WordPress 2.3 Dexter is out loose » Techtites
September 29th, 2007 at 7:08 pm[...] upgrade error? Check out this forum thread. And if you have shell access, read my tutorial on Upgrading WordPress via Shell. And, do remember to deactivate all plugins before you upgrade. Liked this article? Stay [...]
-
Pingback from MOST MOST » Blog Archive » Faster Multiple Wordpress Upgrades via Shell Access
January 16th, 2008 at 6:29 am[...] If you run one wordpress blog, then probably you can follow the full upgrade instructions and finish in about 15-30 minutes. But what if you have multiple wordpress blogs to upgrade? Ajay points to a fast way to upgrade wordpress via Shell. [...]
-
Pingback from Wordpress 2.5 and The Definitive upgrade Resources | Ruhani Rabin | Tech, Life and Thoughts
March 27th, 2008 at 11:18 pm[...] Upgrading WordPress Via Shell [...]
-
Pingback from Blog de Kilgore » Blog Archive » Mise à jour de Wordpress en français par connexion SSH
April 5th, 2008 at 9:03 pm[...] Source : Techtites [...]




March 3rd, 2007 at 8:30 pm
I use cp -R –remove-destination for my copy command. Do you think it’s still necessary to remove old files first when upgrading dot releases?
I did remove directories this last time because of the 2.1.1 issues.
March 3rd, 2007 at 8:52 pm
Typo on line 7? Shouldn’t it be:
rm -rf ./wordpress/
March 3rd, 2007 at 8:52 pm
@Scott, I have used
-fin the above code. It ensures that the files are overwritten.You can also use
-–remove-destinationinstead.@Mark, Thanks. Have corrected the same.
March 3rd, 2007 at 9:59 pm
I personally download the tar.gz file locally and then use “rsync -avrz [local dir] [remote location]” to update the remote files. (I have Linux on my local system). It requires fewer commands and you don’t need to run commands on the server.
It’s more comfortable that way. However, your idea is also good.
March 3rd, 2007 at 10:14 pm
Hi Hari,
rsync seems like a good option too if you are running Linux. There also seems to be a Windows package. Gonna take a look at this in detail.
Thanks.
March 3rd, 2007 at 11:09 pm
I created a script using your commands and was able to upgrade several sites very short order…
Thanks!
March 3rd, 2007 at 11:16 pm
Hi Paul,
Glad to know it worked well for you!
March 3rd, 2007 at 11:30 pm
I put up a post a bit over a week ago with a linux shell script to auto-magically download and upgrade a blog installation to the new version.
Download and details available from my Wordpress Blog: http://krell.cellsandbytes.net/2007/02/22/wordpress-upgrade-script/
March 4th, 2007 at 12:05 am
Keith, the link is throwing up a 404. I guess the permalinks are messed up on your blog.
March 4th, 2007 at 12:24 am
Caught and corrected. Thanks for catching that, Ajay. The permalink should be working now.
March 4th, 2007 at 12:28 am
You had a typo in step 6 and forgot to exit from the wordpress directory before you try and delete it.
6. cp -rpf –reply=yes * ../
7. cd ..
8. rm -rf ./wordpress/
9. rm -f latest.tar.gz
March 4th, 2007 at 12:29 am
Sorry.
6. cp -rpf –reply=yes * ../
March 4th, 2007 at 12:57 am
Thanks Matt. Missed that… Strangely no one earlier checked it…
Anyway, the files wouldn’t get deleted previously.
March 4th, 2007 at 1:09 am
I use a shell-script for this that works on all WP-installs so far, not just 2.1.2.
See this blogpost on my weblog.
March 4th, 2007 at 1:23 am
Fabulous idea, and I like the simplicity of the script. However the script has a few minor issues that should be pointed out …
1 - permissions are not taken care of. What user are you running this script as? Are there any permissions that need updating afterwards?
2 - you are running it from the Wordpress document root and that might be included in the instructions.
Also note that the cp command on my Linux system does not accept the
-reply=yesparameter as valid. I believe the parameter should be
- -reply=yes(no space between the two dashes, that’s just for this comment to display both dashes)However my cp command notes that this is deprecated, and to use
-finstead. Your script already includes this parameter though so perhaps there’s no need for the -reply=yes?
March 4th, 2007 at 1:24 am
Ajay, what do you refer when you tell login via shell. I have never done that before, can you explain that a bit?
March 4th, 2007 at 1:32 am
@Kirk, only the -f on my version of Linux (CentOS 4.4) kept prompting me hence I needed to use
--replyWordPress seems to be changing the double dash to a single one. Just modified the code above with four dashes, so it works correctly.
I’ve also updated the post with a note addressing the two points you raised above. I faced the problem, but assumed that most users would be logging in with their own accounts.
@Mr. Byte, your host needs to give you shell or SSH access so you can login to your installation. The server should be a Linux/Unix server. It is similar to the command prompt in Windows.
March 4th, 2007 at 2:01 am
Wow. I just tried this out on one of my domains and I can’t believe how quick it is!
Until 30 minutes ago my procedure was to download the latest version to my PC, unzip it and upload it again via Dreamweaver and then perform the upgrade.
You are a genius! This will make it much easier to stay on top of my WordPress upgrades!
March 4th, 2007 at 2:13 am
You know what would be useful (since I’m a bit of a *nix noob), what’s the command to tar the contents of a directory? Presumably if we run that in advance, we’ll have a neat little archive just in case things go wrong!
March 4th, 2007 at 6:13 am
Gerard, if you check out the link to my script above which works in a similar manner, it will create a backup of your existing wordpress installation before replacing it with the new files.
March 4th, 2007 at 8:45 am
@Gerard, I’m no genius, just a little guy trying to find easier ways to do things!
Keith’s script is good as it does the job neatly and if want to run a single script. My commands above can be converted into a script as well. I prefer to run it manually.
In case you wish to create a backup of the folder, run
tar -cvvf home.tar home/where home gets replaced by your blog folder. You can also rungzip -c home.tar > home.tar.gzto compress the file you created above.I prefer just backing up the database, as it is the most important component.
March 4th, 2007 at 9:28 am
“You’re” == “you are”. You want “your”.
Also, the first time I tried submitting this comment, it incorrectly told me I got the anti-spam sum wrong. In actual fact, the problem was that it didn’t like the fact that my browser didn’t send a Referer header.
March 4th, 2007 at 9:37 am
Yeah , I guess I have access to shell. I have cPanel in Linux server, I usually update through fantastico…
March 4th, 2007 at 9:50 am
@Jim, Thanks for the correction… small oversight, big grammatical error!
But, I do hope you use your correct email address next time.
@Mr. Byte, Having cPanel doesn’t mean you got shell access. Write to your hosting company and ask them to enable it. You will then need to use a SSH client like Putty.
March 4th, 2007 at 12:04 pm
Hey Ajay
Fantastic steps to upgrade..thanks a lot..
March 4th, 2007 at 12:28 pm
You’re welcome Nici
March 4th, 2007 at 1:28 pm
Oh is it…. will ask them… already I have problem with php mail() function in my server… Probably i’ll do it through fantastico itself…
March 4th, 2007 at 7:59 pm
I prefer to build each new release into its own directory structure and then update the site by repointing a symlink. This means the previous version is still there so you can revert or refer to it whenever you need to. So, if you’re currently on 2.0.7:
cd /var/www/html
mv -v wordpress wordpress-2.0.7
ln -s wordpress-2.0.7 wordpress
Once you have done this (and not before!) you can upgrade using a script like this:
#!/bin/bash
NEW_VERSION="wordpress-2.1.2"
cd /tmp
wget http://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
cd /var/www/html
mkdir $NEW_VERSION
cp -rfp wordpress/* $NEW_VERSION
rm -rf $NEW_VERSION/wp-includes
rm -rf $NEW_VERSION/wp-admin
cp -rfp /tmp/wordpress/* $NEW_VERSION
rm -rf wordpress
ln -s $NEW_VERSION wordpress
March 4th, 2007 at 8:22 pm
But, by leaving the old files, aren’t you leaving your server open for exploit?
March 5th, 2007 at 12:26 am
But, by leaving the old files, aren’t you leaving your server open for exploit?
No, the old versions are not externally accessible.
March 5th, 2007 at 12:36 am
Then there is no problem …
March 5th, 2007 at 12:54 am
Being bilingual, I can tell you that your instructions will remove the /wp-includes/languages folder which is necessary if someone is using localizations. If used as is, this would obviously break most of my clients’ websites…
Besides that, I think the thinking is sound and wish WordPress would offer some upgrade feature which would simply the whole process for everyone involved.
March 5th, 2007 at 1:00 am
@Jean, Thanks for pointing this out… I’ve updated the notes above.
March 5th, 2007 at 1:26 am
EasyWPUpdate is another way to upgrade WordPress and do backups of current files and database all in one script. Has been working well for me for multiple sites for the last few upgrades.
March 5th, 2007 at 5:47 am
Nice one mate, this was so much simpler than doing it manually through FTP
Appreciate it!
March 5th, 2007 at 10:15 am
@Kevin, thanks for pointing this script out.
@James, you’re welcome
April 7th, 2007 at 8:21 pm
#4 hari,
The rsync way is very slick indeed, I wondered I had no thought of that.
I used a port on Windows called cwrsync which did the job perfectly and took 9 seconds to update the whole site.
It would be easy to write a script to wget the latest file, untar it and rsync it all using your local machine.
April 7th, 2007 at 9:21 pm
When you copy the new files over the old installations, doesn’t that include the new wp-content in it and will overwrite the existing one? I think there must be a step to delete the wp-content from the tarred folder so that it does not overwrite the old one before you start copy. Please correct me if I’m wrong.
April 8th, 2007 at 10:37 am
@Yves, I still have to try rsync out.
@Haitham, unless you have customized the default theme (you should run your own theme), you have nothing to worry about why overwriting
wp-contentOctober 28th, 2007 at 1:07 am
doing this worked for me, changing “username” to your actual regular user account name.
before running this for the first time on a server, I found I had to “su” in as root to have permission to overwrite existing files, so the first time I run:
1. su root
2. cd /home/username/public_html/blog
3. chown -R username *
4. su username
then the script runs fine, on this, and any future upgrades.