Establishing parental control: easy when you know how

This content is 15 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

This week, Channel 4 is running a series of sex education television programmes looking at how young people today are gaining their sex education from Internet porn – and as a result are exposed to some disturbing content on the web.

I like to think that I’m fairly open-minded but my eldest son is reaching the point where I am considering giving him his own computer and, whilst I’d like to think that his computer time will be supervised, that will not always be possible as he grows up, or when he uses systems at friends’ houses, school, Internet cafés, etc..

One of the points that Channel 4 is highlighting is the lack of awareness (and knowledge, based on visits to a PC World, Sony Store and Micro Anvika stores) about the parental controls that are available in modern operating systems so, in this post, I’ll give a quick rundown of how to set up parental controls on your child’s PC – without resorting to additional software like that listed on the Kids’ safety advice on GetNetWise.

First up, the operating system on most of the world’s PCs – Microsoft Windows. Windows XP may not have any parental controls within the operating system but Vista and 7 do – as long as you are not running in a domain! Yes, that’s right – no parental controls on domain-joined PCs. I suspect this is something to do with the prospect of being hauled up in front of the United States Department of Justice or the European Union Competition Commission by the vendors of content filtering solutions if businesses relied on the controls built into the operating system to stop their employees from visiting the less salubrious portions of the web but for me, with several domain-joined PCs in the home, this effectively means my children will have to use their own PC. Not necessarily an issue but nevertheless an unnecessary constraint, particularly for those who have a single PC used for both home and business activities and also joined to a corporate domain (perhaps in a small business environment).

Assuming that your Windows Vista or Windows 7 PC is not joined to a domain, it’s parental controls are accessed via Control Panel and include limits on web content, limits on computer access times and games, as well as the ability to block access to specific applications. More information on Windows Parental Controls is available on the Windows help site and it’s also possible to view activity reports.

Over on the Mac, it’s pretty much the same story – OS X 10.4 (Tiger) and 10.5 (Leopard) include parental controls in the user account properties. In addition, OS X can display a simplified Finder window for young or inexperienced users, only allow access to certain applications, hide profanity in the dictionary (yes, I used to look up rude words in a paper dictionary when I was a boy!), limit website access (including the ability to create allow and deny lists) limit the users with whom mail and IM can be exchanged, enforce computer time limits (with different limits for weekdays and weekends!) as well as bedtime on school nights and weekends (I should try setting this on my own account).

The principles are similar in Windows and on the Mac but I’m using the Mac in these screen grabs (because my Windows machines are domain-joined). If I search for the first thing that a schoolboy might think of when given Internet access, it’s blocked:

Parental Controls preventing website access in Safari on Mac OS X 10.5

Unless I happen to know the administrator password:

Parental Controls requesting authentication on Mac OS X 10.5

Similarly, if I try to open an image, using an application that’s not allowed (in this case the OS X Preview application)… computer says “no”:

Parental Controls preventing application access on Mac OS X 10.5

And, assuming I’m not watching over my child like a hawk, I can keep an eye on their computing activities from a distance using the logs:

Parental Controls logging activity on Mac OS X 10.5

By now, you have probably got some idea of what’s possible on the mainstream consumer operating systems. Over in Linux-land it’s a little more complicated but still possible using a combination of IP filters, third party applications and limited DNS (e.g. OpenDNS). I’m sure I’ll write more as I become exposed to child computing habits but, for now, hopefully this has highlighted the ability to easily put in place some controls to protect your children from the Internet, whilst simultaneously allowing them some freedom.

Using the Nikon Scan 4.0.2 plugin with Adobe Photoshop CS3 on an Intel Mac running OS X 10.5

This content is 15 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

Tonight is my local camera club meeting and it’s competition night, which meant I needed to make prints from some of my recent images. After an emergency trip to HobbyCraft last night to buy some mats to mount the prints (unfortunately it was too late in the day to catch the local picture framer), I set to work on tweaking the images before printing them (hence the requirement to buy some extra ink yesterday!!!). The digital files were fine but two of the images to enter in the competition needed to be scanned from film, which meant setting up my Nikon Super Coolscan 4000 ED with my MacBook (running OS X 10.5.5) and Nikon Scan 4.0.2 as a plugin Adobe Photoshop CS3.

A couple of years ago, I wrote about installing Nikon Scan as Photoshop CS2 plugin on my Mac Mini but things have moved on since then. I hadn’t realised that the Nikon Scan plugin is a PowerPC application (and my Macs have Intel processors) and under CS2 (which ran on OS X’s Rosetta emulation layer) this wasn’t a problem but I couldn’t get CS3 (which is a Universal application) to recognise the plugin (incidentally, my original advice to copy the plugin to the Photoshop plugins folder works, but there is an alternative – simply add the path to the legacy plugin in the Photoshop preferences):

Enabling Nikon Scan in the Photoshop preferences

Select Rosetta emulation for Photoshop CS3The answer is to adjust the file information the Photoshop CS3 application to open it using Rosetta (information found on a photo.net forum post). After this is done, Photoshop CS3 is happy to run the plugin, although the interface is not at all Mac-like (and Nikon have stated that they will not be updating Nikon Scan for full OS X 10.5 compatibility). I could use alternative scanning tools (like VueScan) but, despite the awful user interface, Nikon Scan serves its purpose and includes support for the ICE features of my scanner.

It’s worth pointing out that Rosetta is limited to accessing 1.5GB of memory for all non-Intel processes. As I have 4GB of RAM in my MacBook, that’s starving Photoshop of resources, so it’s worth turning off Rosetta when Nikon Scan is not required. Alternatively I could run Nikon Scan as a standalone application but I prefer to run applications like this as plugins.

Incidentally, for those who are interested, these are the pictures I’ll be entering in tonight’s competition:

Silverton HotelTornadoSt Pancras International (2)Basilique du Sacré-Coeur from Musée D'Orsay

(These images are ©1993-2009 Mark Wilson, all rights reserved and are therefore excluded from the Creative Commons license used for the rest of this site.)

[Update 22:30: the St Pancras International image was awarded third place in the open category! The others didn’t make the cut]

Tracking down the source of my overheating MacBook

This content is 16 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

My home office is a warm place. I don’t have a thermometer in here, but there is a fair amount of IT kicking out a fair amount of heat. Even so, there are two machines that make a noticeable difference – the Fujitsu-Siemens Lifebook S7210 that I use for work, and my Apple MacBook – both of which have 2.2GHz Intel Core2Duo CPUs (T7500 “Merom”) and 4GB of RAM. Admittedly, the MacBook has also been upgraded with a 320GB disk but Apple now offers a similar, if not identical, option in its current MacBook White model.

It’s quite normal to hear the fan blowing on the MacBook, and iStat Menus regularly suggests temperatures of 50-60°C, but last weekend it seemed the fan was running almost non-stop, and I saw reported CPU temperatures in the high 80s (even peaking at 90°C). After shutting down many applications to reduce the load on the system (iTunes, Photoshop and Bridge CS3, VMware Fusion) and ejecting my external hard disk, it still wasn’t coming down, so I began to have a look around on the ‘net.

The best advice I found was on a Mac Rumors forum post which suggest running up Activity Monitor to see which process was driving up the CPU utilisation (and therefore making the machine run hot)… sure enough, it was a Norton AntiVirus process!

It may have been co-incidence that the product doing this was one which has such a bad name as a resource hog (I’m told the 2009 products are not as resource hungry as their predecessors but this is Norton AntiVirus 11 for Mac, which, according to the copyright notice, dates back to 2007). Whatever the cause, killing that process dropped the CPU utilisation and within seconds the machine was back down to a more normal level.

Installing Mac OS X 10.5 on a Lenovo S10e (using a retail DVD)

This content is 16 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

Hackintosh Finder Icon by ~3ncI enjoy installing things that shouldn’t work together and making them work. I’m not clever enough to write the hacks but I’m OK at putting together the constituent pieces of the puzzle (with a little help from Google!). This time, the project was installing Mac OS X on my Lenovo S10e – at around 1.25kg and with a 10-inch display, this could be thought of as the ultimate Mac Mini!

Since I was given permission to install Windows 7 on the notebook PC that I use for work, my netbook (which was purchased for Windows 7 testing… at least until my son inherits it when he needs a PC for school) has been a little under-utilised. But with the MacBook now tethered to a monitor and acting to all intents and purposes as if it’s a desktop PC, the netbook would be a great little web-surfing Mac for use when I’m on the move.

There are plenty of guides for installing OS X on netbooks, but most of them involve downloading cracked distributions of the operating system. The difference here is that I didn’t do that – I used a retail OS X 10.5 (Leopard) DVD instead – and, although it may technically be a breach of Apple’s EULA (I’m no lawyer and, like most normal people, cannot comprehend pages and pages of “small print”), because the software was bought and paid for, I figure it’s at least morally acceptable and my karma should be OK.

I have installed OS X on a non-Apple PC before but the experience wasn’t great. Meanwhile the Hackintosh community has made significant progress, and Boing Boing’s Mac OS X netbook compatibility chart suggested that I should be able to get most of the devices in my S10e working. So, this is my guide to building a small, lightweight, “Mac” notebook , for around £400. Or, to put it another way, about half what you’d pay for an entry-level Apple laptop (MacBook) that’s not as well built.

To do this, you will need:

These are the steps that worked for me (based on John Mahoney’s post linked above – which was itself based on a tutorial on the MyDellMini forum by bmaitais but sadly taken down by Dell – combined with funkobongrip‘s retail install guide for the Lenovo S10e – also linked above):

  1. Prepare the USB Drive:
    • On a Mac, use Disk Utility to create two partitions on the drive – a 200MB FAT32 partition labelled TYPE11 and a Mac OS X Extended (Journaled) partition labelled OSXDVD (and make sure that a GUID partition table is in use).
    • On a Windows PC, run syslinux -ma driveletter: from the win32 folder in the SysLinux download to make the TYPE11 partition bootable (there is no confirmation of success).
    • Extract the contents of the DellMiniBoot123 toolset to the TYPE11 partition, taking care not to overwrite the ldlinux.sys file.
    • Back on a Mac, insert the OS X install DVD and, using Disk Utility, create a new image, saved as live.dmg on the OSXDVD partition (it should be compressed and unencrypted).
    • Extract the System and Library folders from the OSXDVD.zip file (linked above) to the OSXDVD partition (to make OS X think that the USB stick is an actual installation DVD).
    • Copy the kernel from the Mac to the OSXDVD partition using sudo cp /mach_kernel /Volumes/OSXDVD.
    • Extract the OS X drivers for the Lenovo S10e (linked above) to a folder (e.g. Drivers) on the OSXDVD partition.
  2. Boot the S10 from the USB drive and press Fn+F3 until the display appears on the external monitor (only).
  3. Select the OSXDVD boot option (I have a feeling that DellMiniBoot123 should have given me a menu option to do something with the TYPE11 partition but it didn’t seem to, which I put down to the fact that I wasn’t running it on a Dell Mini – and v8.02beta produced a kernel panic, so getting anything working with v8.01 was a huge step forward – I’ve since read that 8.01 is for OS X 10.5.5 and earlier DVDs, 8.02 is for 10.5.6).
  4. The OS X Installer should run and, on the welcome screen, select Disk Utility from the Utilities menu.
  5. Partition the hard disk (I created a single Mac OS X Extended (Journaled) partition called Macintosh HD and exit Disk Utility.
  6. Continue the installation as normal and when it completes, allow the system to boot from the USB drive.
  7. At the boot: prompt, press the Esc key, then type 81 (for the second hard disk – I spent ages trying to work out why 80 wouldn’t work for me – but my USB drive was showing up as the first hard disk in the system so 81 was the internal hard drive).
  8. Back at the boot: prompt, press Fn+F3 until the display appears on the external monitor (only) and type -f -s -v to bring the system up in single user (verbose) mode, loading all kernel extensions (.kexts).
  9. Enter the following commands:
      /sbin/fsck -fy (and look for the volume name Macintosh HD – if it’s something like OS X Installation DVD then you are working on the USB drive!)
      /sbin/mount -uw /
      cd /System/Library/Extensions/IO80211Family.kext/Contents/PlugIns/AppleAirPortBrcm4311.kext/Contents
      nano Info.plist
  10. Insert <string>pci14e4,4315</string>
  11. (in sequence with the similar PCI device IDs) then save and exit Info.plist.

  12. Enter the following commands:
      cd /System/Library
      rm Extensions.mkext
      exit
  13. At this point, the OS X installer should continue, setting up the regional and keyboard settings, before presenting the option to transfer information from another Mac. I chose not to transfer information and was unable to connect to my wireless network (it eventually failed). The installer then moved on to allow me to complete registration details (not submitted), take a picture with the camera (for my account details) and set the timezone.
  14. Mount and run Chameleon_DFE_for_Hard_Disk.dmg from the /bootloader folder (in the S10e drivers archive).
  15. Run Kext Helper from the /tools folder (in the S10e drivers archive) and install the kernel extensions found in the /driver/system folder (AppleACPIBatteryManager.kext; AppleACPIPlatform.kext; AppleDecrypt.kext; ApplePS2Controller.kext; AppleSMBIOS.kext; and Disabler.kext).
  16. Restart the system and boot from the internal hard disk (on my system that was hd (0,2) Macintosh HD), then press the return key at the boot: prompt.
  17. Run Network Diagnostics to join a WiFi network.
  18. Run Software Update to upgrade to OS X 10.5.6.
  19. After rebooting there will be no WiFi, so enter -s -v at the boot: prompt and repeat steps 9-11. As the machine boots up you should see a message about the link being up on en0 (even link down shows that the device has been found!).
  20. Apply other software updates (for me that was Airport Utility v5.3.2; Airport Utility Software Update v5.41; QuickTime v7.6; iTunes v8.0.2; iLife Support v9.0.1; Airport Client Updater 2009-001 v1.0; Jave for Mac OS X 10.5 Update 2 v1.0; Safari v3.2.1; and Security Update 2009-001 v1.0) – if the downloads appear to have stuck, nudge the trackpad and the screen should refresh!
  21. After restarting there will be no WiFi, so enter -s -v at the boot: prompt and repeat steps 9-11.
  22. Using Kext Helper, install one of the sets of kernel extensions found in the /driver/display folder (in the S10e drivers archive) – I used the option with brightness controls but no mirroring (AppleIntelGMA950.kext and AppleIntelIntegratedFramebuffer.kext) and copy the com.apple.Boot.plist file to /Library/Preferences/SystemConfiguration.
  23. Restart the system and it should should start up with no requirement to select a boot option, running at 1024x576px with 32-bit colour depth.
  24. Using Kext Helper, install one of the sets of kernel extensions found in the /driver/fan folder (in the S10e drivers archive) (AppleACPIPowerSource.kext and AppleACPIThermal.kext), then copy the DSDT Patcher utility to a temporary folder, run it (selecting 0 for Darwin when prompted) and copy the resulting dsdt.aml file to the root folder on the internal hard disk.
  25. Restart the computer and, using Kext Helper, install one of the sets of kernel extensions found in the /driver/sleep folder (in the S10e drivers archive) (ClamshellDisplay.kext and EHCISleepEnabler.kext).
  26. Edit /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBEHCI.kext/Contents/ to include:
      <key>OSBundleCompatibleVersion</key>
      <string>1.0</string>

    under:
      <key>CFBundleVersion</key>
      <string>3.1.5</string>
  27. Replace the depency in AppleACPIThermal.kext by editing /System/Library/Extensions/AppleACPIPlatform.kext/Contents/PlugIns/AppleACPIThermal.kext/Contents/Info.plist to change the depency version below the key com.apple.driver.AppleACPIPlatform to 1.2.4 (from 1.2.1).
  28. Restart the computer and install CHUD.pkg and AzaliaAudio.pkg from the /driver/sound folder (in the S10e drivers archive).
  29. Restart the computer and run Audieee from the /driver/sound folder (in the S10e drivers archive).
  30. Run OSX86Tools from the /tools folder (in the S10e drivers archive) to modify the CPU information in About This Mac (e.g. 1.6GHz Intel Atom).
  31. Finally, restart the computer – and hopefully, you now have a Hackintosh!
  32. About This Mac - on a netbook

Notes

  • This post is based on the work of a lot of clever people to whom I’m very grateful for sharing their experiences – I hope I’ve credited them all!
  • I’ve been running this for just over a week now and it seems pretty solid but your mileage may vary.
  • There seems to be a game of cat and mouse going on whereby posts are added to the MyDellMini Forums (this advice can be adapted for the Lenovo S10), then taken down (like this one), then new ones appear. Since I got my system running I found this comprehensive thread.
  • I still have to get some things working: if I let the machine go to sleep without switching off Bluetooth (using the button above the keyboard), it may not come back; and I have no wired Ethernet connection (only WiFi). There may be other items too that I have not noticed but I do have the following working: TrackPad; keyboard (although some of the key mappings are incorrect on a UK keyboard – Apple keyboards have the @ and the ” in the wrong places – even on the UK variants); display (1024×576); WiFi; Bluetooth; audio; camera; SD card reader; and ExpressCard slot.
  • Some dialogue boxes have buttons that appear off screen – this trick to scale the resolution may help (I haven’t tried it yet).
  • The Kitch has also written about installing Mac OS X on a Lenovo S10 or a Dell Mini 9 and the everyday Mac netbook. The menooB Hackintosh tutorial for installing a Mac Leopard OS X Retail DVD on a PC might also be useful.

Archive Google Mail to a Mac using getmail

This content is 16 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

Late last year I questioned the wisdom of trusting critical data to the cloud and cited Google Mail as an example. Whilst the Google Mail service is generally reliable, there have been some well-publicised instances of failure (including data loss). I shouldn’t be too alarmed by that – for many things in life you get what you pay for and I pay Google precisely nothing (although they do get to build up a pretty good profile of my interests against which to target advertising…). So, dusting off the motto from my Scouting days (“Be Prepared”), I set about creating a regular backup of my Google Apps mail – just in case it ever ceased to exist!

I already use the Apple Mail application (mail.app) for IMAP access but I have some concerns about mail.app – it’s failed to send messages (and not stored a draft either) on at least two occasions and basically I don’t trust it! But using Mac OS X (derived from BSD Unix) means that I also have access to various Unix tools (e.g. getmail) and that means I can take a copy of my Google Mail and store it in maildir or mbox format for later retrieval, on a schedule that I set.

The first step is to install some Unix tools on the Mac. I chose DarwinPorts (also known as MacPorts). After running the 1.7.0 installer, I fired up a terminal and entered the following commands:

su - Administrator
cd /opt/local/bin
sudo ./port -d selfupdate

This told me that my installation of MacPorts was already current, so set about installing the getmail port:

sudo ./port install getmail

The beauty of this process is that it also installed all the prerequisite packages (expat, gperf, libiconv, ncursesw, ncurses, gettext and python25). Having installed getmail, I followed George Donnelly’s advice to create a hidden folder for getmail scripts and a maildir folder for my GmailArchive – both inside my home directory:

mkdir ~/.getmail
mkdir ~/GmailArchive/ ~/GmailArchive/new ~/GmailArchive/tmp ~/GmailArchive/cur

I then created and edited a getmail configuration file at ~/.getmail/getmailrc.mygmailaccount) and entering the following settings:

[retriever]
type = SimpleIMAPSSLRetriever
server = imap.gmail.com
username = googleaccountname
password = googleaccountpassword

[destination]
type = Maildir
path = ~/GmailArchive/

[options]
verbose = 2
received = false
delivered_to = false
message_log = ~/.getmail/gmail.log

I tested this by running:

/opt/local/bin/getmail -ln --rcfile getmailrc.gmailarchive

but was presented with an error message:

Configuration error: SSL not supported by this installation of Python

That was solved by running:

sudo ./port install py25-socket-ssl

(which installed zlib, openssl and py25-socket-ssl), after which I could re-run the getmail command and watch as my terminal session was filled with messages being downloaded (and the folder at ~/GmailArchive/new started to fill up). Then I saw a problem – even though I have a few thousand messages, I noticed that getmail was only ever downloading the contents of my Inbox.

Eventually, I solved this by adding the following line to the [retriever] section of the getmail configuration file:

mailboxes = ("[Google Mail]/All Mail",)

This took a while to work out because many blog posts on the subject suggest that the mailbox name will include [GMail] but I found I needed to use [Google Mail] (I guess that could be the difference between GMail and the Google Mail service provided as part of Google Apps). After making the change I was able to download a few thousand messages, although it took a few tries (the good news is that getmail will skip messages it has already retrieved). Strangely, although the Google Mail web interface says that there are 3268 items in my All Mail folder, getmail finds 5320 (and, thankfully, doesn’t seem to include the spam, which would only account for 1012 of the difference anyway).

In addition, the getmail help text explains that multiple mailboxes may be selected by adding to the tuple of quoted strings but, if there is just a single value, a trailing comma is required.

Having tested manual mail retrieval, I set up a cron job to retrieve mail on a schedule. Daily would have been fine for backup purposes but I could also schedule a more frequent job to pull updates every few minutes:

crontab -e

launched vim to edit the cron table and I added the following line:

4,14,24,34,44,54 * * * * /opt/local/bin/getmail -ln --rcfile getmailrc.gmailarchive

I then opened up a terminal window and (because running lots of terminal windows makes me feel like a real geek) ran:

tail -f ~/.getmail/gmail.log

to watch as messages were automatically downloaded every 10 minutes at 4, 14, 24, 34, 44, and 54 minutes past the hour.

This also means that I get 6 messages an hour in my the local system mailbox (/var/mail/username) to tell me how the cron job ran so I chose to disable e-mail alerting for the cron job by appending >/dev/null 2>&1 to the crontab entry.

Many of the posts on this subject suggest using POP to download the mail, but Google limits POP transfers so it will require multiple downloads. Peng.u.i.n writes that IMAP should help to alleviate this (although that wasn’t my experience). He also suggests using several mbox files (instead of a single mbox file or a maildir) to backup mail (e.g. one file per calendar quarter) and Matt Cutts suggests backing up to mbox and maildir formats simultaneously:

[destination]
type = MultiDestination
destinations = (’[mboxrd-destination]‘, ‘[maildir-destination]‘)

[mboxrd-destination]
type = Mboxrd
path = ~/GmailArchive.mbox

[maildir-destination]
type = Maildir
path = ~/GmailArchive/

If you do decide to use a mbox file, then it will need to be created first using:

touch ~/GmailArchive.mbox

In Chris Latko’s post on pulling mail out of Gmail and retaining the labels, he describes some extra steps, noteably that the timestamps on mail are replaced with the time it was archived, so he has a PHP script to read each message and restore the original modification time.

Aside from the MacPorts installation, the process is the same on a Unix/Linux machine and, for Windows users, Gina Trapani has written about backing up GMail using fetchmail with Cygwin as the platform.

Getting Vodafone Mobile Connect and Mac OS X to play nicely together

This content is 16 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

VodafoneA couple of years back, I wrote about getting Vodafone Mobile Connect (VMC) to work with Windows Vista and today, after spending most of my train journey from Milton Keynes to Crewe trying the same on a Mac (it’s actually a hackintosh… but that’s of little consequence here), it seems I need to repeat the experience for the benefit of Mac users.

It seems that, even with the latest version of Vodafone Mobile Connect (I’m using v2.11.02.00 on OS X 10.5.6) it’s necessary to run the application as the root user (yes, root!) the first time it is used.

Thankfully, Ian Jindal thought to write about his experiences with Vodafone Mobile Connect on the Mac (which he referred to as inept and unnecessary), summarised as:

  1. Install VMC (I did this as a standard user).
  2. Enable the root user account (with a password of root) in Directory Utility.
  3. Log out and log back in as root.
  4. Run VMC (I tested the connection at this stage too).
  5. Disable the root user.
  6. Log out and log back in using a standard user account.

Once you’ve done this, it should be possible to connect to Vodafone as required using the appropriate connection in the network preferences. The software might not be up to scratch, but the network is generally pretty good (in fact, it’s better than the corporate connection I’ve been on all day!).

Vodafone 3G connection on Mac OS X

I’m writing this at the station so let’s see how I get on as I make my way home courtesy of Virgin Trains (who I noticed were advertising an enhanced connection for Orange customers on some of their trains, but there’s no mention of anything for Vodafone).
Vodafone USB Broadband

Installing WordPress on a Mac: the aftermath (phpMyAdmin, databases, themes, plugins and fixing the tags)

This content is 16 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

Last week I wrote about installing WordPress on a Mac but I wanted to follow that up with a post on what happened next.

Installing phpMyAdmin

Installing WordPress is all very well, but it’s good to be able to manipulate the database. The command line mysql tools would have worked but a graphical interface (even an ugly one with bizarre icons) is often easier, so I installed phpMyAdmin as described by Nino Müller:

  • Download the latest version of phpMyAdmin (I used v3.1.2).
  • Extract the files to ~/Sites/phpmyadmin.
  • Copy config.sample.inc.php to config.inc.php and edit the Blowfish secret (the line which reads $cfg['blowfish_secret'] = ''; .
  • Navigate to http://localhost/~username/phpmyadmin and login.

Unfortunately, after attempting to logon, I was presented with an error message:

#2002 – The server is not responding (or the local MySQL server’s socket is not correctly configured)

Following The Vince Wadhwani’s advice at his Hackido site I typed mysqlconfig --socket to verify the socket is in use for MySQL (e.g. /tmp/mysql.sock) but I couldn’t find a config.default.php file (or the equivalent entry in my config.inc.php file) to adjust the socket. A post at Friends of ED suggested creating a symbolic link for the socket and it seemed to work for me:

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Following this I could log into phpMyAdmin (although I still have a warning message that phpMyAdmin cannot load the mcrypt extension – this doesn’t seem to be causing any problems though).

Importing a WordPress database

Using phpMyAdmin on my web host’s server, I exported the database from the live copy of markwilson.it and attempted to import it on the Mac. Unfortunately this didn’t work as my database was too large for PHP to upload – as confirmed by creating a file named ~/Sites/phpinfo.php containing <?php phpinfo(); ?>, then viewing it in a browser (http://localhost/~username/phpinfo.php) and looking for the upload_max_filesize variable.

Rather than messing around with my PHP configuration, I googled for the necessary commands and typed:

/user/local/mysql/bin/mysql -u root -p
drop database wordpressdatabasename;
source ./Downloads/wordpressdatabasename.sql
quit

At this point, the local copy of WordPress was running on the live database, but the links were all to the live site, so I used phpMyAdmin to edit the site URL in the wp_options table, changing it from http://www.markwilson.co.uk/blog to http://localhost/~username/blog.

Because the live copy of the site is on an old version of WordPress, browsing to http://localhost/~username/blog/wp-admin prompted me to upgrade the database, after which I could log in and edit the site settings (e.g. the blog address).

WordPress database upgrade

WordPress 2.7 Dashboard

Restoring the theme and plugins

At this point, although WordPress was running on a local copy of my live database, the normal theme was missing and the plugins were disabled (as they were not present). I copied them from the live server and, after selecting the theme and enabling the plugins saw something approaching normality, although there were a few plugins that required updating and I still couldn’t get rid of a particularly annoying database error:

WordPress database error: [Table ‘wordpressdatabasename.wp_categories’ doesn’t exist]
SELECT cat_name FROM wp_categories ORDER BY cat_name ASC

By disabling plugins one by one (I could also have grepped /~Sites/blog/wp-admin/wp-content/plugins for wp_categories), I found that the issue was in the Bad Behavior plugin that I use to ban IP addresses known to send spam.

Moving from categories to tags

When I first moved this site to WordPress, I used Dean Robinson’s Ultimate Category Cloud plugin to provide a tag cloud (at that time WordPress did not support tags). Over time, that because unmanageable and, although I still need to define a decent taxonomy for the site, the categories still have some value if they are converted to tags.

Over some tapas and drinks in the pub, my friend Alex Coles at ascomi and I had a look at the database structure and Alex came up with a quick SQL query to run against my WordPress database:

UPDATE wp_term_taxonomy SET taxonomy='post_tag' WHERE taxonomy='category'

That converted all of my categories to tags, but there were some I manually edited to return to categories (General – which was once called Uncategorised – and Site Notices) but for some reason, all the posts were recorded in a category of Uncatagorized. Some late night PHP coding (reminiscent of many nights at Uni’ – as Steve will no doubt remember – although in those days it was Modula-2, C, C++ and COBOL) resulted in a script to run through the database, identify all posts with a category of 17 (which in my database is the default category of “General”), put the post numbers into an array and then explicitly set the category as required, taking a note of the ones which have been changed so that they can be ignored from that point on:

<html>
<head>
</head>

<body>
<?php

// Connect to the WordPress database
$db_hostname = "localhost:/tmp/mysql.sock";
$db_username = "wordpressuser";
$db_password = "wordpresspassword";
$db_connect = mysql_connect($db_hostname, $db_username, $db_password) or die("Unable to connect to server.");
$db = mysql_select_db("wordpressdatabasename",$db_connect);

// Retrieve all objects including a category with the value of 17 (my default category)
$hascat = mysql_query("SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id = '17' ORDER BY object_id");
echo '<p>'.mysql_num_rows($hascat).' rows found with category</p>';

$correct_ids = array();

// Build a PHP array (not a MySQL array) containing the relevant object IDs for later comparison
while ($row = mysql_fetch_array($hascat))
{
$correct_ids[] = $row[0];
}
echo '<p>Array built. Length is '.count($correct_ids).'. First ID is '.$correct_ids[0].'.</p>';

// Retrieve every object
$result = mysql_query("SELECT * FROM wp_term_relationships ORDER BY object_id");
echo '<p>'.mysql_num_rows($result).' rows found total</p>';

// The magic bit!
// If the object is not in our previous array (i.e. the category is not 17)
// then add it to category 17 and put it in the array so it won't get added repeatedly
while ($row = mysql_fetch_array($result))
{
if (!in_array($row['object_id'],$correct_ids))
{
// Add to category 17
mysql_query("INSERT INTO wp_term_relationships (object_id,term_taxonomy_id,term_order) VALUES ('".$row['object_id']."','17','0')");
echo '<p>Alter database entry for object '.$row['object_id'].'.</p>';
// Add to the array so it is not flagged again
$correct_ids[]=$row['object_id'];
}
else echo '<p style="color:white; background-color:black">'.$row['object_id'].' ignored.</p>';
}

?>
</body>
</html>

Remaining issues

Permalinks don’t seem to work – it seems that Mac OS X does not support using .htaccess files by default and, whilst it’s possible to modify for the root folder it doesn’t seem to work for individual user sites. I’ll do some more digging and see if I can find a fix for that one.

WordPress also features the ability to automatically update plugins (and itself), but my installation is falling back to FTP access when I try to update it and making it work appears to be non-trivial. Again, I’ll take another look when I have more time.

Installing WordPress on a Mac

This content is 16 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

The software platform which markwilson.it runs on is in desperate need of an updated but there is only me to make it happen (supported by ascomi) and if I make a mistake then it may take some time for me to get the site back online (time which I don’t have!). As a result, I really needed a development version of the site to work with.

I thought that it would also be handy if that development version of the site would run offline – i.e. if it were served from a web server on one of my computers. I could run Windows, IIS (or Apache), MySQL and PHP but as the live site runs on CentOS, Apache, MySQL and PHP it makes sense to at least use something similar and my Mac fits the bill nicely, as a default installation of OS X already includes Apache and PHP.

I should note that there are alternative stacks available for running a web server on a Mac (MAMP and XAMPP are examples); however my machine is not a full web server serving hundreds of users, it’s a development workstation serving one user, so the built in tools should be fine. The rest of this post explains what I did to get WordPress 2.7 up and running on OS X 10.5.5.

  1. Open the System Preferences and select the Sharing pane, then enable Web Access.
  2. Web Sharing in OS X

  3. Test access by browsing to the default Apache website at http://computername/ and a personal site at http://computername/~username/.
  4. Download the latest version of MySQL Community Server (I used mysql-5.1.31-osx10.5-x86_64) and run the corresponding packaged installer (for me that was mysql-5.1.31-osx10.5-x86_64.pkg).
  5. After the MySQL installation is completed, copy MySQL.PreferencePane to /Library/PreferencePanes and verify that it is visible in System Preferences (in the Other group).
  6. MySQL Preferences in OS X

  7. Launch the MySQL preference pane and start MySQL Server (if prompted by the firewall to allow mysqld to allow incoming connections, allow this). Optionally, select automatic startup for MySQL.
  8. MySQL running in OS X

  9. Optionally, add /usr/local/mysql/bin to the path (I didn’t do this, as creating a .profile file containing export PATH="$PATH:/usr/local/mysql/bin" seemed to mess up my path somehow – it just means that I need to specify the full path when running mysql commands) and test access to MySQL by running /usr/local/mysql/bin/mysql.
  10. Enable PHP by editing /etc/apache2/httpd.conf (e.g. by running sudo nano /etc/apache2/httpd.conf) to remove the # in front of LoadModule php5_module libexec/apache2/libphp5.so.
  11. Test the PHP configuration by creating a text file named phpinfo.php containing <?php phpinfo(); ?> and browse to http://localhost/~username/phpinfo.
  12. With Mac OS X, Apache, MySQL and PHP enabled, start to work on the configuration by by running /usr/local/mysql/bin/mysql and entering the following commands to secure MySQL:
    drop database test;
    delete from mysql.user where user = '';
    flush privileges;
    set password for root@localhost = password('{newrootpassword}');
    set password for root@127.0.0.1 = password('{newrootpassword}');
    set password for 'root'@'{hostname}.local' = password('{newrootpassword}');
    quit
  13. Test access to MySQL. using the new password with /usr/local/mysql/bin/mysql -u root -p and entering newrootpassword when prompted.
  14. Whilst still logged in to MySQL, enter the following commands to create a database for WordPress and grant permissions (I’m not convinced that all of these commands are required and I do not know what foo is!):
    create database wpdatabasename;
    grant all privileges on wpdatabasename.* to wpuser@localhost identified by 'foo';
    set password for wpuser@localhost = old_password('wppassword');
    quit
  15. Download the latest version of WordPress and extract it to ~username/Sites/ (i chose to put my copy in a subfolder called blog, as it is on the live site).
  16. Configure WordPress to use the database created earlier by copying wordpressdirectory/wp_config_sample.php to wordpressdirectorywp_config.php and editing the following lines:
    define('DB_NAME', 'wpdatabasename');
    define('DB_USER', 'wpuser');
    define('DB_PASSWORD', 'wppassword');
    define('DB_HOST', 'localhost:/tmp/mysql.sock');
  17. Restart Apache using sudo apachectl restart.
  18. If WordPress is running in it’s own subdirectory, copy wordpressdirectory/index.php and wordpressdirectory/.htaccess to ~/Sites/ and then edit index.php so that WordPress can locate it’s environment and templates (require('./wordpressdirectory/wp-blog-header.php');).
  19. Browse to http://localhost/~username/wordpressdirectory/wp-admin/install.php and follow the “five minute WordPress installation process”.
  20. WordPress installation

  21. After installation, the dashboard for the new WordPress site should be available at http://localhost/~username/wordpressdirectory/wp-admin/.
  22. WordPress fresh out of the box (dashboard)

  23. The site may be accessed at http://localhost/~username/wordpressdirectory/.
  24. WordPress fresh out of the box

Credits

I found the following articles extremely useful whilst I was researching this post:

Live Mesh reaches out to the Mac

This content is 16 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

Graphic showing files moving between devicesOn the same day that I published my recent post about Windows Live FolderShare, I heard that the current Live Mesh beta is now available on a Mac.

Despite already being a Mesh user, I tried to add my Mac as a device but was disappointed to read that the Live Mesh Tech Preview was out of invitations so I tried again this evening and was pleased to find that it accepted me and let me install the software.

First impressions were good, with a really straightforward installation and good client support – working like a Mac application (not a Windows application running on OS X) and with support for both Safari and Firefox.

Then I realised that Mac-PC synchronisation in Mesh still needs to go via the Live Desktop (i.e. out to the ‘net and back), as evidenced when I tried to sync a folder that was not fully replicated:

The current version of Live Mesh cannot synchronize a folder with a Mac computer unless the folder is also synchronized with your Live Desktop.

This lack of LAN-based peer-to-peer support, combined with Mesh’s 5GB storage limit means that FolderShare is still the sync option for my work in progress (be prepared for a long wait if you’re syncing via the web and an ADSL connection – ADSL downloads are fine, but uploads are s…l…o…w…).

Predictably, some features are Windows-only too (like the remote desktop capability). There’s mobile device support too but it does depend on the phone – for example my Apple iPhone 3G was recognised as a Mac, after which Safari refused to install anything (I didn’t expect it to work but I just had to try!).

I don’t want to sound negative – Live Mesh is has so much potential and it is still a beta – over time new features will be added and it will be fantastic. Right now it’s still a little confusing – with the feature sets of Windows Live Skydrive, Mesh, FolderShare and Office Live Workspaces all overlapping slightly it’s sometimes difficult to fathom out the best tool to use – and those are just the Microsoft options! Hopefully this will all shake down over the coming months and the vision of my digital life being available wherever I am will become a reality.

Hate Windows UAC? Have you actually tried the alternatives?

This content is 16 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

The next time somebody complains about Windows User Account Control (UAC), I’d like them to actually try using a Mac as a standard user (i.e. not the default setting, which is an Administrator, albeit not the root user). I’m in the process of applying Apple’s latest 10 updates, which are huge (I didn’t notice the total for all 10, but I it was well over half a gigabyte – just one HP Printer Driver Update was 142MB and the Mac OS X 10.5.5 update is 321MB).

In the intervening time, during which I’ve been writing this post on another PC, I’ve had to enter my Administrator credentials four five six times to allow Apple Software Update to do its thing. Mac OS X (and Linux) use a time-based system whereby once I’ve entered my elevated credentials they are valid for a set period but at least once I’ve told Windows Update that I do want to install a bunch of updates, that process (and any child processes) are then allowed to continue unhindered. It seems that the answer for me should really be to use setuid and make Apple Software Update run elevated but that is not necessarily a good idea either.

I guess there are advantages and disadvantages to either approach (actually, the time-based approach has a significant weakness in that any process can run elevated during that window) but the real point is that UAC is there for our protection – and it’s not really that big a problem in my experience.

Meanwhile, for hardcore Windows users that would like to implement an equivalent of the Linux/OS X setuid command in Vista (or Windows Server 2008, I guess), Joel Bennett explains how to do it with PowerShell.