Most of you probably already know that WordPress powers a large amount of websites that we look at every day. With the large userbase and support, you can do a lot of cool things with it. While WordPress even offers one-click upgrades to the latest WP versions, some people simply can’t use it because their server doesn’t support it, they don’t have any FTP accounts (maybe you uploaded files using SSH?), or whatever else the reason may be. If this is the case, you’ve more than likely had to update your site by manually copying over the new files. However, there’s really no need to do that anymore, as you can set up your WordPress site in a way where updating is much more simple.
I will be explaining how to create a brand new WordPress blog on your Linux server using Subversion (SVN) as well as how to convert a “traditional” installation to an SVN-type installation, as most people who will want to do this probably already have a blog going. This is possible because Automattic (the creators of WordPress) operate a SVN repository that allows this functionality. Without this repository, none of this would work.
Before you start, you’ll probably need to install the Subversion version control software onto your server. For Ubuntu and Debian servers, use
sudo apt-get install subversion
while Fedora /Red Hat/CentOS users should use
sudo yum install subversion
Creating A New Blog
In order to create a new SVN-controlled WordPress instance, log into your server using a program such as PuTTY, using :
so you can use
to create a new folder named blog in your current location. Then use
to go into the new folder, and run
svn co http://core.svn.wordpress.org/tags/3.2.1 .
to download and install WordPress into the current folder. If there is a newer version, replace 3.2.1 with the latest version. Also, don’t forget to include that lonesome period (.) at the end of the command as that is needed for the command to run correctly. Wait for the process to complete, then you can go ahead and enter in the correct URL to begin the installation script.
Converting From “Traditional” To SVN
Converting your blog to be controlled by SVN will require a few new steps. Essentially, this will create a new blog that is SVN-controlled, and move all your content and settings over to that new blog. This isn’t as invasive as it sounds, and shouldn’t mess up anything that you currently have on your blog.
To get started, use “cd” to go to where your blog folder is located (don’t actually go into the blog folder). Here we are going to assume that your old blog is in a folder named “blog” and your temporary new blog is going to be in a folder named “blog-new“. Go ahead and run
svn co http://core.svn.wordpress.org/tags/3.2.1 blog-new
which will create the new “blog-new” folder and download the necessary files into it. Please make sure that you download the same version as the one you are currently using. So if you’re not running the latest version, don’t choose the latest version in this process.
Next we’re going to go into the old blog folder by running
and then copy the main config file as well as the htaccess file by running
cp -p wp-config.php .htaccess ../blog-new
so that these important files are in the new blog folder.
Now we’re going to copy over the actual content of your blog to the new folder, including plugins, themes, and whatnot. To do this, run
cp -rpfu wp-content/* ../blog-new/wp-content
and let that take a couple seconds or more, depending on how large your blog is. WordPress-provided plugins shouldn’t be affected, but you can double-check to make sure everything is running smoothly by running
svn status ../blog-new/wp-content
Any files that were modified will have an “M” next to them and need to be reverted by using
svn revert ../blog-new/wp-content/some/file
Any custom files or directories can also be copied by running
cp -rp images wp-digest ../blog-new
You can check that everything is copied over correctly and good to go by running
diff -rq blog/ blog-new/ | grep -v svn
(This is an example after I intentionally removed some files)
We’re almost done! We’re now going to move out to the big folder containing the two blog folders by running
and then renaming them to make the final switch-a-roo by running
mv blog blog-old; mv blog-new blog
Congrats! Your SVN-controlled blog should now be up and running! If not, you may have forgotten to copy something from the old blog (now located in the renamed folder “blog-old”). You can now go ahead and update to the latest version if needed.
Updating Your Blog
To update your SVN-controlled WordPress blog, you’ll need to go into the directory of your blog using the “cd” command and then run :
svn sw http://core.svn.wordpress.org/tags/3.2.1/ .
which will switch your blog to the newest version. Remember to replace 3.2.1 with the latest version available.
For those that support it, Subversion version control is a great version tracking tool that is highly effective, relatively easy to use, and very fast. It’s a great thing that WordPress can be controlled via SVN, increasing the flexibility of the already-flexible WordPress platform. No wonder it’s one of the most used frameworks for sites today.
What do you think about WordPress and SVN working together? Have you even known that this was possible? Let us know in the comments!
Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.