Tag: osx


Setting up Snow Leopard for Web Development

My trusty old 1st-gen MacBook Pro died on me last week, so I’ve got myself a shiny new one, which is exciting! One thing I was looking forward to was a clean install of the OS, so I could re-appraise the way I used my computer. One of the things I decided to do was to move away from using XAMPP and have a more traditional set up using the built-in Web Sharing. Here, I’m going to talk about what I’ve done and how I propose to use my new laptop for Web Development to smooth my workflow.

Apache and PHP

Mac OS X Snow Leopard comes with Apache and PHP, although PHP is disabled by default. I didn’t know this to begin with, so I started off by installing Marc Liyanage’s PHP bundle. However, after installing this I found that I was getting 301 “Permanently Moved” errors on all my pages, so that was soon uninstalled.

To enable PHP on Snow Leopard, you need to open the config file in your favourite text editor (mine’s TextMate, but you can use vim, nano, or any other). In a terminal, open the file for editing (replacing ‘mate’ with the command for your text editor) entering your password when prompted.
sudo mate /etc/apache2/httpd.conf
You’re looking for a line like this:
#LoadModule php5_module        libexec/apache2/libphp5.so
If it exists, remove the # symbol, otherwise add the line in, minus the #. Save the file and exit the editor. Now you need to restart the Apache server, so type the following in the terminal:
sudo apachectl restart
You can test whether it’s worked by creating a file in your Sites directory that looks like this:
<?php phpinfo(); ?>
Call this file info.php, and then in your browser navigate to http://localhost/~yourusername/info.php – if it’s worked then you should see a nice table which has all the details of the PHP installation.


If, like me, you’re going to be using MySQL for the database side of your web applications, then you’re in luck! It’s really easy to install, since MySQL provide some lovely .dmgs. Go to http://dev.mysql.com/downloads/mysql/ and choose the DMG archive most appropriate for you (remember to check your operating system version, and whether your computer is 32 or 64 bit). Note that all of these downloads are for Intel-based Macs only. When you’ve got the file, open it up and you’ll see 4 files. Start by installing the main MySQL application which will be called something like mysql-5.1.50-osx10.6-x86_64.pkg. When that’s done, I installed the MySQLStartupItem.pkg and the MySQL.prefPane files (both done by double clicking on them), which starts the MySQL server when I login and lets me control it through the System Preferences application.

You can manage the database in a number of ways, but I choose to use SequelPro. It’s a free application that’s got all the features you need in a lovely Cocoa-based UI. If you prefer, you could install phpMyAdmin or one of a number of alternatives, but I haven’t tried those so I shan’t give you any advice on them.

Starting Development

Now you’ve got all the components set up, it’s time to create some web apps! All the code will go in the Sites folder that’s located in your home directory. I’m going to be following Remy Sharp’s guide, which sets up domain names that point to your local machine (so, for example, I could develop and view on my local machine at the url http://imaginaryroots.dev). There’s quite a lot of work involved in that, so I intend to write a shell script to do the majority for me, but I haven’t gotten around to it yet…

Now all’s that’s left is to knuckle down and write some code – and let’s face it, isn’t that why we’re all here?


MySQL gem on OSX with XAMPP

I’ve just upgraded to Snow Leopard, and as a result, have had to reinstall my MySQL gem for Rails. On OSX, this is never easy, as the sheer number of blog posts offering advice will show. Having tried all the different solutions I could find, this is how I managed it. Note that because I am on a Core Duo machine (not a Core 2 Duo), I didn’t upgrade to the 64 bit version of MySQL.

Open up a Terminal, and edit the .profile file, to add the following to modify your path:

export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH"


sudo sh env ARCHFLAGS="-arch i386" gem install mysql

You might see a load of warnings, but as long as it doesn’t fail, then they’re not too important. You can check it’s worked by running:
gem list -d mysql

This way you don’t need to bother with all the setting mysql_config flags. Or, at least, I didn’t need to. Hopefully this will work for you!



I’ve been working for the last couple of days on a project for my band Drongo Sealion Magic. We use a lot of samples in our music, all of which we store as MP3s on a laptop, and we wanted a simple playing mechanism which was more responsive than something like QT or iTunes. Unfortunately, we didn’t have much luck finding one, so I thought I would write one. More on that later.

One of the things I want to have is a file browser so you can quickly change the samples you’ve got loaded. For some reason though, Cocoa doesn’t appear to have a standard File Browser object. This is something I think is a bit odd. I can understand the reasoning, obviously most applications will make do with the Open/Save dialogues, and those that don’t probably need some form of custom browser anyway. But surely, for consistencie’s sake, they would want developers to present a standard browser so that people would be using the same browser across all their apps? As it stands, I’m having a hard time replicating the look and feel of the standard list browser in Finder. Perhaps someone should write an “NSFileBrowser” style class. Perhaps it should be me…


Coincidence Averted?

So the problem appears to be solved. The issue was that on waking from sleep, the laptop would crash. Then, when trying to start it up again, it would not even get as far as the Apple logo screen before failing. The solution to this was to hold the power button until the light flashed and a high picthed noise was heard. I’m not sure what exactly this does, but it made the laptop start up.

After some searching around, I found this article pertaining to sleep modes. I did what it said, and changed my hibernate mode to 0, and now the laptop seems fine. Also, I’ve saved myself a precious 2GB worth of hard drive space, which on only a 70GB drive, is very much worth it! It does mean, however, that I can’t leave it on sleep for long periods of time, since it drains the battery to keep the contents of the RAM happy. I think I can live with that, though.



Tomorrow, Apple are set to be launching new MacBooks and MacBook Pros.

Today, my MacBook Pro broke.

I think the gods at Apple are trying to tell me something…


OS X Mouse Following Issues

I’ve found a problem on my iMac which is a bit odd. OS X doesn’t seem to be able to trace my mouse movements. This manifests itself in a number of issues, some of which are outlines below:

  • The dock doesn’t magnify
  • When a select a menu, and then hover over the options, the options don’t turn blue (i.e. the hover state isn’t activated)
  • Similarly, when I select a menu and then move across to the next menu, the first menu remains open.
  • The x, – and + symbols on the window action buttons (close, minimize, resize) don’t appear on mouse over.

Now, my MacBook Pro has the same version of OS X, both are up to date, and only the iMac has the problem. I suppose it could be a PowerPC issue, since the iMac is a G5 and the MBP is intel, but I can’t find other people complaining of a similar issue. I wonder if it’s some spyware or similar that’s found its way onto my system – there don’t appear to be any suspect process in Activity Monitor though. It’s not the mouse, either, same issue with different mice.

Has anyone else found this problem? Anyone got any solutions?

Solution! I zapped my PRAM, and everything seems to work fine. I wasn’t entirely sure the zapping worked, but it appears to have done. So yay!