My preferred method for installing WordPress is to check it out from the Subversion repository (http://svn.automattic.com/wordpress/). Recent versions of WordPress have added support to allow wp-config.php and wp-content to live outside of the WordPress directory. Here’s the steps to make your setup work as a Subversion check out (based on Sam‘s WordPress Plus Subversion slides) in a subdirectory:
- Assumptions:
- Domain is example.com
- Installing in root directory of the domain: /home/example.com/public_html/
- Web server and MySQL database/username already setup and working correctly
- cd /home/example.com/public_html/
- mkdir wp
- svn co http://svn.automattic.com/wordpress/branches/2.7/ wp (could be any branch, tag or -trunk)
- Install WordPress at http://example.com/wp/
- mv wp/wp-config.php wp-config.php (moves wp-config.php from /home/example.com/public_html/wp/ to /home/example.com/public_html/)
- mkdir wp-content
- Add WP_CONTENT_DIR and WP_CONTENT_URL after WP_LANG to wp-config.php:
[sourcecode language=”php”]
…
define (‘WPLANG’, ”);define( ‘WP_CONTENT_DIR’, dirname( ABSPATH ) . ‘/wp-content’ );
define( ‘WP_CONTENT_URL’, ‘http://example.com/wp-content’ );/* That’s all, stop editing! Happy blogging. */
…
[/sourcecode] - cd wp-content
- mkdir plugins
- cd plugins
- ln -s ../../wp/wp-content/plugins/akismet .
- cd ..
- mkdir themes
- cd themes
- ln -s ../../wp/wp-content/themes/default .
- Update WordPress settings in wp-admin:
- Settings -> General -> WordPress address (URL): http://example.com/wp/
- Settings -> General -> Blog address (URL): http://example.com/
- Permalinks:
- Settings -> Permalinks -> Custom Structure: /archives/%year%/%monthnum%/%postname%/ (my preferred format, you can choose your own if you’d like)
- .htaccess:
[sourcecode language=”php”]
RewriteEngine On
RewriteBase /RewriteRule ^wp/wp-content/(.*)$ wp-content/$1 [R=301,L]
RewriteRule ^wp-admin/(.*)$ wp/wp-admin/$1 [R=301,L]
RewriteRule ^$ /wp/index.php [L]RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
[/sourcecode]
You can update WordPress at any time by running ‘svn up’ in /home/example.com/public_html/wp/. Updating when a new major release comes out means switching branches, for 2.8 that would ‘svn switch http://svn.automattic.com/wordpress/branches/2.8/’.
When logging in remember that wp-admin is at http://example.com/wp/wp-admin/.
I’ve also run into a few plugins that need fixing, because they lookup the WP URL via get_bloginfo( ‘wpurl’ ) instead of get_bloginfo( ‘home’ ). The problem with ‘wpurl’ is it returns http://example.com/wp/, making it reference the wp-content directory that came with WordPress (http://example.com/wp/wp-content/) instead of the one that you are actually using at http://example.com/wp-content/. The wp-content redirect in the .htaccess file should help make this a bit less painful by redirecting /wp/wp-content/ requests to /wp-content/.
If you’ve setup /home/example.com/public_html/ as it’s own Subversion repository you can make WordPress an external for the /home/example.com/public_html/wp/ directory. That way you’ll still be able to have a pristine setup of WordPress while being able to manage wp-config.php, themes and plugins in your own repository.