WordPress with SVN Externals

I’ve read through a number of articles about using svn externals to setup a wordpress install and none of them were quite accurate or worked as written for myself (probably due to most being written previous to wordpress 3.0 but I haven’t verified and don’t wish to do so). I thought it was a good idea to log my instructions so that I could easily replicate it and if anyone else has troubles perhaps this will help you out.


  1. you have a clean svn repository to start with
  2. you are working from the root of your websites docroot
  3. you are comfortable with wordpress and svn already
  4. wordpress 3.1.3 is the latest release, we’ll initially start working with 3.1.2 to show the ease of upgrade to 3.1.3
  1. Checkout your repository into a working copy:
    svn co https://svn.example.com/example/trunk example
  2. Enter your working copy and setup the wordpress core via externals
    cd example
    svn pe svn:externals .

    Then enter the following and save:

    wordpress http://svn.automattic.com/wordpress/tags/3.1.2
  3. You can do an update and you’ll receive the wordpress core
    svn up
  4. Lets create our themes/plugins/uploads directories
    mkdir -p wp-content/themes wp-content/plugins wp-content/uploads
    svn add wp-content
  5. With the themes directory now created and added we can add some themes, lets get the twentyeleven theme and the delicate theme.
    svn pe svn:externals wp-content/themes

    Then enter the following and save:

    twentyeleven http://core.svn.wordpress.org/tags/3.1.2/wp-content/themes/twentyten
    delicate http://themes.svn.wordpress.org/delicate/3.4.3
    svn ci -m 'add base directories'
    svn up
  6. You will now see you have your wordpress core and a theme checked out from wordpress 3.1.2, next step is to setup the wordpress config. Copy the base wordpress config file, config the database connections and add additional content to setup for the new directory structure.
    cp wordpress/wp-config-sample.php wp-config.php
    vi wp-config.php

    Enter the following anywhere before the “/* That’s all, stop editing! Happy blogging. */” line and be sure to set all the other db settings etc as necessary:

    define('WP_HOME', 'http://example.com');
    define('WP_SITEURL', WP_HOME);
    define('WP_CONTENT_URL', WP_HOME.'/wp-content');
    define('WP_CONTENT_DIR', realpath(ABSPATH.'../wp-content'));
  7. Next up is the .htaccess file, create one and enter the following contents:
  8. # BEGIN WordPress
            RewriteEngine On
            RewriteBase /
            RewriteCond %{REQUEST_URI} ^/wp-(.*)(.php) [OR]
            RewriteCond %{REQUEST_URI} ^/wp-includes [OR]
            RewriteCond %{REQUEST_URI} ^/wp-admin
            RewriteRule ^(.*)$ /wordpress/$1 [L]
            RewriteCond %{REQUEST_URI} !^/wordpress/
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ /wordpress/index.php
            RewriteRule ^(/)?$ wordpress/index.php [L]
    # END WordPress
  9. You can now visit your site, fill in the details and complete the online install as normal. You will have to re-activate (or choose another) theme as the path to the default theme isn’t accurate because of the base install, so choose the delicate theme or any other theme of your choice in order to see the homepage after install.
  10. Now the magic of running this through svn externals is that you can update the core or any themes plugins with a couple quick commands. For example to update the wordpress core to 3.1.3 you just have to change the externals value and do a svn up and you’re done like below:
    svn pe svn:externals .

    Then update the current entry to the following:

    wordpress http://svn.automattic.com/wordpress/tags/3.1.3

    And then do an update

    svn up

All of this can be applied to the plugins/themes at anytime for adding and updating which makes things really fast and easy. It’s great in an environment where you work with a team and have developed some internal plugins or themes that you like to reuse you can link in any common required plugins and all your sites receive the updates together, no more merging in changes to separate projects.

One thought on “WordPress with SVN Externals

  1. Pingback: Upgrade Wordpress Install to Use SVN Externals | Wes DeBoer

Leave a Reply

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