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 http://svn.example.com/projects/wpblog -m "Creating blog directory"
mkdir blog
cd blog
svn co http://svn.example.com/projects/wpblog .
svn propset svn:externals . -F < (cat <<EOF
 core http://core.svn.wordpress.org/tags/3.5.2/
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', 'http://www.example.com/blog/wp-content');
define('WP_HOME', 'http://www.example.com/blog');
 
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]
</ifmodule>
# END WordPress
EOF
svn add .htacess
svn ci .htaccess -m "Add .htaccess"
cd wp-content/plugins/
svn rm akismet
http://plugins.svn.wordpress.org/
svn propset svn:externals . -F < (cat <<EOF
 akismet http://plugins.svn.wordpress.org/akismet/tags/2.5.7
 any-hostname http://plugins.svn.wordpress.org/any-hostname/tags/1.0.3/
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