Running WordPress and Plugins from an SVN repository

Tags: ,

The process of installing/updating WordPress using Subversion is well documented, but keeping your entire WordPress installation in SVN is less-well documented, although there are several people who’ve also thought along these lines and have documented what they’ve done.

Here’s my take on it, very closely related to PB30’s method linked above, but with some enhancements…

svn mkdir -m "Creating blog directory"
mkdir blog
cd blog
svn co .
svn propset svn:externals . -F < (cat <<EOF
svn ci -m "Add externals for Wordpress"
svn export core/wp-content wp-content
svn add wp-content
svn ci wp-content/ -m "Add wp-content"
cp core/wp-config-sample.php wp-config.php
svn add wp-config.php
svn ci wp-config.php -m "Add default wp-config.php"

Edit the wp-config.php file and add your database configs, as well as the following three lines:

define('WP_CONTENT_DIR', realpath(ABSPATH.'../wp-content/'));
define('WP_CONTENT_URL', '');
define('WP_HOME', '');
svn ci wp-config.php -m "Add database and wp-content settings"
cat < <EOF > .htaccess
# BEGIN WordPress
<ifmodule mod_rewrite.c>
  RewriteEngine On
  # Base is the URL path of the home directory
  RewriteBase /blog/
  # Serve the main page
  RewriteRule ^$ core/index.php [L]
  # Serve real files and directories directly
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  # Serve uploads and plugins directly
  RewriteRule .* - [L]
  # And serve everything else from the core directory
  RewriteRule ^(.*)$ core/$1
  # Skip real files and directories
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  # Otherwise send it to WordPress
  RewriteRule .* core/index.php [L]
# END WordPress
svn add .htacess
svn ci .htaccess -m "Add .htaccess"
cd wp-content/plugins/
svn rm akismet
svn propset svn:externals . -F < (cat <<EOF
svn ci -m "Add akismet and any-hostname"
svn up

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Loading Facebook Comments ...

Leave a Reply