Posts Tagged ‘system administration’

Website maintenance and tweaks

Keeping WordPress up to date

I originally installed WordPress using Subversion. This provides a really easy way for me to update WordPress:

svn switch http://core.svn.wordpress.org/tags/3.4.1

Replace 3.4.1 with the latest version number. Then I visit the admin panel of the blog and it will redirects me to perform any necessary database upgrades.

Use .htaccess to prevent access to the .svn directory:

# Prevent access to .svn directory
# From http://codex.wordpress.org/Installing/Updating_WordPress_with_Subversion
RewriteEngine On
RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Access Forbidden"

Compression

I’ve learned that content can be categorized into static content and dynamic content. There is an Apache module, mod_deflate, that can compress both types of content seamlessly. It only requires a configuration change in .htaccess, and no changes will need to be made to the application. However, it is inefficient because it recompresses the same content every time someone requests it. For this reason, my web host does not support mod_deflate. Instead, they recommend different tactics for each type of content.

On my blog, an example of dynamic content is the home page, http://www.rratliff.com/. This test or this test can test whether the home page is compressed. At time of writing, I have not found a good way to compress dynamic content.

On my blog, there are several static content files that are typically requested. For example, the CSS and JS files that WordPress includes in every page. Google Page Speed Insights is the a tool that tests compression of every resource needed for loading my blog’s home page, both the dynamic and static pages. I’m looking for a reliable way to compress the static content files that Google Page Speed Insights finds.

Deploying static content

I now have two sections of static content on my website, my Post Voting App and my Portfolio. I’ve adopted a simple solution to keep these sections up to date. Each section is maintained in a github repository. I have a matching repository on my own computer where I make changes, commit, and then push to the github repository. Then, to update the content on my website, I SSH to the host, cd to the directory, and do a git pull.

I reuse the .htaccess code above in order to prevent access to the .git subdirectory. See the .htaccess file for an example.

Backups

I created two scripts to backup the files and the database in my NearlyFreeSpeech site. The scripts aren’t fancy, they just contain one command each.

For the database, I created a non-privileged backup user who has permissions necessary to do a mysqldump on all the tables in my database. Here’s the gist of it. (It should be all one line. Lines wrapped for display purposes.)

ssh user@host mysqldump --user=nonprivilegeduser 
    --password=password --host=mysql_host 
    --all-databases | gzip > backup-file-name-$(date +%Y%m%d).sql.gz

Just change the underlined parts. The $(date) thing creates a filename like this:

backup-file-name-20131029.sql.gz

For the files, I use rsync with the options -aAXE --delete.

A Linux OS for my Eee PC

Two years ago I purchased an Eee PC 900 with a 16GB SSD and Windows XP. I left Windows XP on it and installed Eeebuntu 3.0. At this point I don’t remember if I installed Base or Standard. The Eeebuntu people became the Aurora OS people, and they have not released a stable OS since Eeebuntu 3.0.

Eeebuntu 3.0 is based on Ubuntu Jaunty 9.04, and support for Jaunty recently ended, so I will not be able to get security updates for it. To top it off, Google Chrome realized this, and has been complaining to me that my operating system is obsolete.

Windows XP itself is a bit old, and I don’t use it anyway. I decided to wipe out the entire hard drive and install a new operating system. I picked Xubuntu to try out first. I downloaded the Xubuntu ISO and used Ubuntu’s Startup Disk Creator tool to put it on a usb stick.

Backing up

I booted Xubuntu and used the command line to backup using an external hard drive with enough free space for a 16GB image of the entire Eee PC disk.

First, identify the name of the hard drive:

sudo fdisk -l

Then I ran the following command to backup the hard drive:

time sudo dd if=/dev/sda of=/media/ubuntu-backup/home/bobby/eeepcharddisk-20110620.dd
31522176+0 records in
31522176+0 records out
16139354112 bytes (16 GB) copied, 642.54 s, 25.1 MB/s

real    10m43.059s
user    0m40.083s
sys     5m36.741s

Installing Xubuntu

I used the shortcut on the desktop to start the installation.