Codex tools: Log in / create account
If you have command-line access to your web server, and if your server has a Subversion (svn) client installed, you can use Subversion to install and update WordPress. Although SubVersion is mostly a software developers' tool, non-developers can also use it to install and upgrade WordPress. Some people consider this to be much easier than following the standard WordPress installation and upgrade methods (downloading and unzipping archives, then using FTP to put them on your web host), and this article explains how to do it.
Contents |
First, a little background. Subversion is one of many existing source-code version-control systems; specifically, the version-control system that is used by WordPress. Version-control systems are used by software developers to keep track of their source code and its revisions behind the scenes, and periodically release versions of the software for public use. You can read more about Subversion, Subversion commands, and the use of Subversion in WordPress development in the Using Subversion article.
As detailed in the Using Subversion article, the WordPress Subversion repository has several branches or sections. When you install or upgrade WordPress, you have to choose a branch to use. Your main choices are:
The other decision you need to make is to decide which directory to install your blog in. All examples here assume your blog is installed in a directory called "blog". If your blog is installed in a different directory, you will need to alter the commands shown accordingly.
Note: These instructions do not follow the official WordPress upgrade recommendations of deactivating all plugins and backing up your database before an upgrade. You may still want to do those things. Caveat blogger.
This section of the article assumes you have decided you want to have your blog run the latest "bleeding edge" development version of WordPress, and are willing to put up with bugs. If you would rather run a stable, released version of WordPress, skip down to the "Tracking Stable Versions" section below. If your blog had already been installed by the standard method, read the "Converting" section at the end of the article.
To install a fresh copy of WordPress, type the following at your command prompt, starting from the directory above where you want to install WordPress. These commands will create a directory "blog" for your blog, and then check out (Subversion command "co"), or extract from the repository, the latest "trunk" version of WordPress. Do not type the "$" characters -- they are just indications of the command prompt. Here are the commands:
$ mkdir blog
$ cd blog
$ svn co http://svn.automattic.com/wordpress/trunk/ .
The trailing slash on the URL, and that period at the end of the command, are both important - they make sure that downloaded files from the repository end up in the current directory; leave off that dot and you'll end up creating a new installation directory (which would be called "trunk"), which is not what you want if the current directory is the intended installation directory.
When download is complete, copy wp-config-sample.php to wp-config.php and edit wp-config.php, then access your blog URL to complete installation, as in the standard WordPress installation instructions.
Some time later, you may decide that you want to update so that you are running the latest trunk version of the WordPress software. To do that, log in and use the Subversion "update" (up) command:
$ cd blog
$ svn up
Doing so will overwrite any changed WordPress-provided files, while leaving any custom or privately owned files, plugins, and themes alone. In other words, it should be safe (but make a backup, just in case).
Run the usual wp-admin/upgrade.php and you're done.
This section of the article assumes you have decided you want to have your blog run a stable version of WordPress. If you would rather run an unstable version in development, go back to the "Tracking Trunk" section above. If your blog had already been installed by the standard method, read the "Converting" section at the end of the article.
The next thing you will need to do is decide which exact version of WordPress you would like to install. The examples in this section assume you want to install particular version numbers; if you want to install a different version, substitute that version number.
To install a fresh copy of WordPress, type the following at your command prompt, starting from the directory above where you want to install WordPress. These commands will create a directory "blog" for your blog, and then check out (Subversion command "co"), or extract from the repository, the stable version of WordPress you have chosen. Do not type the "$" characters -- they are just indications of the command prompt. Here are the commands (assuming the version you want is 2.5.1):
$ mkdir blog
$ cd blog
$ svn co http://svn.automattic.com/wordpress/tags/2.5.1 .
The period at the end of the command is very important - it makes sure that downloaded files from the repository end up in the current directory; leave off that dot and you'll end up creating a new installation directory (which would be called "tags/2.5.1"), which is not what you want if the current directory is the intended installation directory.
When download is complete, edit wp-config.php, then access your blog URL to complete installation, as in the standard WordPress installation instructions.
The next time WordPress releases a new version, you will probably want to upgrade to that version. To do that, log in and use the Subversion "switch" command (sw) to switch to a new version (assuming the new version is 2.5.1):
$ cd blog
$ svn sw http://svn.automattic.com/wordpress/tags/2.5.1/
Doing so will overwrite any changed WordPress-provided files, while leaving any custom or privately owned files, plugins, and themes alone. In other words, it should be safe (but make a backup, just in case).
Run the usual wp-admin/upgrade.php and you're done.
You can visit http://svn.automattic.com/wordpress/tags, the "tags" section of the Subversion repository, to find the list of tagged versions of WordPress.
If you originally installed your blog without subversion, but now want to convert it to installing/upgrading with Subversion, this section explains how. The basic steps are:
Of course, backing up the old directory, backing up the database, and disabling all plugins before you start would be advisable.
Here are the details of what commands to type, assuming that your old directory was called "blog", your temporary directory is called "blognew", and the version of WordPress you want to use is the stable 2.5.1 version. As above, do not type the "$" characters -- they are an indication of the command prompt.
First, create the temporary directory and check out WordPress there:
$ mkdir blognew
$ cd blognew
$ svn co http://svn.automattic.com/wordpress/tags/2.5.1 .
Next, copy the old wp-config and .htaccess files to the new site:
$ cd ../blog
$ cp -p wp-config.php .htaccess ../blognew
Next, copy custom files/directories you may have on the old installation into the new one (this may not apply to you). For example, if you have an images directory and a wp-digest file:
$ cp -rp images wp-digest ../blognew
Next, copy plugins, themes, and any uploaded images/media from the old site to the new (all three are stored in the wp-content directory):
$ cp -rpf wp-content/* ../blognew/wp-content
You may have spotted the flaw in that last step - it will overwrite any new WordPress-provided plugins with your old ones. This is probably not an issue, but running svn up (update) after the copy will fix any potential problems.
Now, rename the directories to make the new blog dir into the current site:
$ cd ..
$ mv blog blog-old
$ mv blognew blog
Now that all the files are installed, the last step is to visit the usual wp-admin/upgrade.php URL to allow WP to perform any needed database upgrades. Then you are ready to test all the links and features. If anything isn't working, check to make sure you actually copied all your custom files over from the old site. You shouldn't encounter any problems, but if you do, just move the old directory back into place, and if absolutely necessary, restore your database from backup. Here's how to move the directory names back:
$ mv blog blognew
$ mv blog-old blog
Scripts for automating and managing WP blogs under svn control