Configuring a website on Apache2 with server-side includes

January 22, 2011

I recently got myself involved in helping with a website for a local club. In order to maintain it, I wanted to set up an Apache instance at home as well.

Luckily, in Ubuntu 9.10, it’s almost all set up by default. The only changes I had to make were to change the DocumentRoot directory and enable server-side includes. Here’s what I did:

Changing the document root

First I edited /etc/apache2/sites-available/default to put my document root in DocumentRoot, and also changed the two directory references that did point to /var/www to my new document root. Then I made sure all the parents of my document root had r+x permission for the Apache user.

Turning on server-side includes

My hosting facility has server-side includes turned on for .html. This is not the best use of resources, but this website doesn’t get enough traffic to make a difference. So I added:

AddType text/html .html
AddHandler server-parsed .html
Option Include (plus whatever options were there before)

to the two directories that used to be /var/www and /. After that, I had to enable mod_include with:

cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/include.load include.load

Then restart apache with sudo /etc/init.d/apache2 restart

Installing the Brother MFC 9840cdw driver on Ubuntu

January 2, 2011

When I had Ubuntu 8.04, I’d struggled my way through installing the official Brother driver from the Brother Linux site.

Since then I’ve upgraded a couple of times to 9.10, and had not reinstalled my printer. It turns out Ubuntu has made life much easier for us Brother printer owners – so these days there’s no reason not to install the printer driver, especially if the printer is networked.

Here’s how to do it:

  1. Open Synaptic Package Manager
  2. Search for 9840. You should see two packages:
  3. Select those for installation (along with their required packages).
  4. Go to System->Administration->Printing and press the “New Printer” button.
  5. After a “Search for new printers” message comes up and goes away, expand “Network Printers”.
  6. If you’re lucky like me, you’ll see your printer there. I chose to use the one that was found by IP address (LPD Network Printer via DNS-SD).
  7. Then I printed a test page, which shot a bunch of colour toner out. (If I had to do it over again, I would have just printed from Firefox to save toner.)
  8. Finally, I did System->Preferences->Default Printer to set the new printer as the default.

That does the printer; next you’ll want the scanner. This isn’t quite as straightforward, since the scanner stuff isn’t in Synaptic. Again I’m assuming it’s set up on a network:

  1. Make sure you’ve already installed xsane and its requirements.
  2. Download the .deb for brscan3 from the Brother web site. If you’re like me, you want the 32-bit version.
  3. Install the driver with:
    $ sudo dpkg  -i  --force-all brscan3-0.2.11-2.i386.deb
  4. Configure the scanner:
    $ brsaneconfig3 -a name=SCANNER model=MFC-9840CDW ip=aaa.bbb.ccc.ddd

    (where aaa.bbb.ccc.ddd is your MFC-9840’s IP address).

  5. Verify the driver installed:
    $ brsaneconfig3 -q | grep SCANNER
      0 SCANNER             "MFC-9840CDW"       I:aaa.bbb.ccc.ddd
  6. Run xsane and it should find the scanner.

Reading fonts from a Mac CDROM and converting them to TrueType

August 6, 2010

A few years back, I bought a bunch of Macintosh fonts on a CD-ROM. Recently, I decided I wanted to use them with Ubuntu. Since the Mac CD was HPFS only and very scratched, here’s what I ended up doing.

First, I installed the Ubuntu utilities for Mac HPFS:
sudo aptitude install macutils hfs

Then I tried just mounting the file system:
sudo mount -thfs /dev/cdrom /mnt/cdrom/

That probably would have worked, but my CD was so scratched that it kept dying. (Also, I don’t know if copying from a mounted HFS file system copies both forks of the Apple file.)

Luckily, I was able to use the mounted file system to get a ls -lR listing of the files on the disk. That made it easier to use the excellent hfs utils:

sudo aptitude install hftutils

Then I could:
hmount /dev/cdrom
hcopy -b MyFont.suit /tmp/MyFont.hqx

I wrote a script to copy the files over. Once I had the files over, I could convert them manually using fontforge (from Basically, you do:
sudo aptitude install fontforge
fontforge MyFont.hqx

and then File -> Generate Fonts -> Save (after making sure TTF is selected).

It turns out fontforge is overkill – and also harder to script – than fondu.

sudo aptitude install fondu
fondu *.hqx

Here are some useful sources of information:

A discussion of font utilities:

The easy way: using fondu:

Converting from one outline font (e.g. PostScript) to another (e.g. TrueType):

Once you have the fonts in TTF format, you can copy them to ~/.fonts/ (or use the File Browser to open the Font Viewer and then press the Install button if you’re GUI) to install on Ubuntu.

For Windows, just drag & drop the font to C:\WINNT\Fonts or C:\WINDOWS\Fonts depending on your system.

Incidentally, if you’re looking for a particular font or lookalike, you’ll probably find it here:

A minimal xorg.conf with modeline

March 25, 2010

Back in the Bad Old Days, the X configuration file was miles long and you had to get it all right. Nowadays, X guesses at most things pretty accurately. This means you might not have anything in your xorg.conf file. This makes changing the Monitor section trickier.

Here’s a default xorg.conf file with a modeline. (This is for a Sharp LL-172C-B monitor; your modeline will probably differ.)

Section "Device"
        Identifier      "Configured Video Device"

Section "Monitor"
        Identifier      "Configured Monitor"
        # Modeline "1280x1024"  MHz  HSize HTotal HSyncEnd HSyncDelay  VSize VSyncStart VSyncEnd VTotal -hsync +vsync
        Modeline "1280x1024"  109.00  1280 1322 1450 1700  1024 1027 1034 1066 -hsync +vsync

Section "Screen"
        Identifier      "Default Screen"
        Monitor         "Configured Monitor"
        Device          "Configured Video Device"

Monitoring hard disk health with smartmontools

January 23, 2010

I always install smartmontools when I use SMART-enabled hard drives. It wasn’t until recently, though, that I started automating the tests.

Here’s a link that explains it:

Based on that, here’s the code I added to my /etc/smartd.conf:
# Per
DEVICESCAN -d sat -a -o on -S on -s (S/../.././19|L/../../3/21|C/../.././20) -m root
# -d sat because /dev/sdX doesn't seem to run without it
# S/../.././19 = short test every day at 19:00
# C/../.././20 = conveyance test every day at 20:00
# L/../../3/21 = long test every wednesday (3) at 21:00
# -m root = root will be emailed if anything strange occurs

Note that this has to come before any other DEVICESCAN (apparently the first one takes priority). Don’t forget to kill -HUP the smartd process so the new config will take effect, and make sure /etc/default/smartmontools has uncommented:


After this, you can get useful info with:

sudo smartctl -l selftest /dev/sda

(or whatever drive you care about).

A very good description of the output of smartctl can be found at:

Adding fldigi from the Berlios repository

January 15, 2010

The version of fldigi that’s built for Ubuntu 9.10 is a bit out of date. Luckily, the Berlios repository has a more recent version, and you can install that.

The instructions are here. In short form (specific to Ubuntu 9.10):

  1. Edit /etc/apt/sources.list and add the following lines:
    # Berlios repository for updated FLDigi
    deb karmic main
  2. Get the key for fldigi
    sudo apt-key adv --recv-keys --keyserver 8E7306F5
  3. Install fldigi
    sudo aptitude update; sudo aptitude install fldigi

Automatically mounting drives with UUIDs

December 6, 2009

Until now, I’ve always mounted drives by accessing their devices. However, I ran into a situation where this wouldn’t work. Luckily, Ubuntu has the ablility to access drives by UUID – which solved my problem.

I have a drive that holds networked data, which I mount on Ubuntu 8.04 Server as /data/. I also back that drive up to a drive which is normally read-only as /databackup/.

Both of these drives are SATA – meaning they could be unplugged at any time. If both are unplugged, whichever drive gets plugged in first becomes /dev/sda1 – and the other becomes /dev/sdb1. This means I can’t rely on mounting /dev/sda1 on /data and /dev/sdb1 on /databackup.

To get around this, I mounted the drives using UUID in /etc/fstab. First, I had to figure out what the UUIDs of the drives were. To start with, I killed Samba and unmounted both – I knew /dev/sda1 was /data and /dev/sdb1 was /databackup. Then I obtained the UUIDs of both drives:

$ sudo vol_id --uuid /dev/sda1
$ sudo vol_id --uuid /dev/sdb1

Next, I replaced the device mounts (/dev/sda1 and /dev/sdb1) in /etc/fstab with:

UUID=7b932326-717b-4ba6-bef2-fedfbafcabe6 /data ext3...
UUID=94efd7bd-8498-46f3-ab6d-cb706c413567 /databackup ext3...

Under Ubuntu 9.10, it appears that vol_id has merged into blkid – so now you would use:

$ sudo blkid /dev/sda1
/dev/sda1: UUID="f30ba2a3-9da6-48b1-8ab5-75952ef26cc4" TYPE="ext3"

to determine the UUID, and then update /etc/fstab as you’d do for 8.04.