c o d i n g f r o g s

croaking about programming, programming languages, software engineering, and the business of software

7Mar/100

Even Simpler WordPress Administration on NFSN

I'm a fan of both WordPress and NearlyFreeSpeech.net, which you may have already figured out if you've done a little digging.  This blog is hosted on NFSN using WordPress, as is my personal blog.

Installing WordPress is a fairly straightforward adventure, but this script makes it a little bit easier:

wget http://wordpress.org/latest.tar.gz
tar xvzf latest.tar.gz
cp -R wordpress/* .
rm -rf wordpress

head -44 wp-config-sample.php > wp-config.php
wget http://api.wordpress.org/secret-key/1.1/
cat index.html >> wp-config.php
rm index.html
tail -28 wp-config-sample.php >> wp-config.php

echo "" >> .htaccess
echo "RewriteEngine On" >> .htaccess
echo "RewriteBase /" >> .htaccess
echo "RewriteCond %{REQUEST_FILENAME} !-f" >> .htaccess
echo "RewriteCond %{REQUEST_FILENAME} !-d" >> .htaccess
echo "RewriteRule . /index.php [L]" >> .htaccess
echo "" >> .htaccess

Run this script directly in your document root. You can get a copy of it here.  It grabs the latest version of WordPress and unpacks it, updates your configuration with your own set of unique WordPress keys, and updates your .htaccess file to support the pathname URLs used by WordPress.  Now all you have to do to set up WordPress is set up a database and provide wp-config.php with your database info and you should be good to go.

WordPress updates regularly, which is good news because it means the project is active.  The downside is that this also means upgrading the installation frequently.

To help deal with this I also wrote an upgrade script:

if [ -d "backup" ]
then
        echo "Delete backup directory first."
        exit
fi

mkdir backup
cp -R index.php license.txt readme.html xmlrpc.php wp-* backup

wget http://wordpress.org/latest.tar.gz
tar xvzf latest.tar.gz
cp -R wordpress/* .
rm -rf wordpress

This upgrade is pretty simple but keeps your site intact, including any themes or other content you might have added.  This script is also available here.

I tried this today setting up a new blog as well as upgrading this blog, and the scripts seem to work fine.  Any feedback is welcome.