Mac, Apache, MySQL and PHP (MAMP)

Mac OS X serves as an excellent development environment, even if you are not actually developing Mac OS or iOS applications. It is the darling of many a LAMP (Linux, Apache, MySQL and PHP) developer, who enjoys a slick desktop operating system with good UNIX-like underpinnings but who don’t necessarily want to put up with all the various limitations and complications that running a Linux desktop brings, consistent improvements in this regard over recent years notwithstanding.

The only trouble with this is that if you want to develop LAMP applications and work on a Mac then traditionally you’ve needed a two-box setup; a Mac on your desk and Linux on a development server. For many this isn’t an issue, and indeed when you’ve got a team of developers, optimal, but what if you wanted a self-contained development environment that was restricted to just one box? What if you wanted that box to be your laptop so you could take it anywhere?


“Virtual machine!”, I hear you cry. Yes, this is a possible solution, and for many works well. Good virtualisation software is free these days, but using a local VM is cumbersome. Not only does it consume a large slice of your RAM but it also puts a lot of strain on the CPU, meaning that if you are running off your battery your battery life will be decreased. It’s also cumbersome; you have to start up the VM when you need it and there can be complications with the networking, for example, if you have connected to a public wireless network it’s possible that your VM might not be extended the same resource.

There is a software package for Mac OS called MAMP (the M for Mac OS replacing the L for Linux). This is a point-and-click installer which bundles Apache, Linux and PHP for installation on Mac OS. I don’t like this solution, for a number of reasons, including:

  1. Limited functionality unless you “go pro” (at quite considerable cost). Any self-respecting developer will require multiple virtual hosts as a minimum and won’t need or want a clicky-button interface to get what they want.
  2. You are entirely at the mercy of the distributors of MAMP with regards to component software versions that are made available to you and when.

Alternative solution

There’s an alternative to this. You don’t have to fork out £39 for a package of what it otherwise freely and widely available software. With the help of my friend and colleague Ben Nimmo I present the following assembled and tested instructions for turning your Mac into a native MAMP server without using the packages download.


  1. Download and install the latest .dmg and install both the *.pkgs within it (don’t use the TAR/GZ archives). You may wish to install the Workbench too, it’s really good these days.
  2. Find where the mysql.sock file is expected to be in /etc/php.ini (should be /var/mysql/mysql.sock)
  3. Create the folder and link the socket file to the expected location.
sudo mkdir /var/mysql
sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock
  1. Add MySQL to command line by editing /Users/username/.bash_profile and adding this line and then either restarting terminal or source-ing the file:
export PATH=$PATH:/usr/local/mysql/bin


PHP comes with Mac OS, so it’s not necessary to download and install it, however, there are a couple of necessary steps to configure it:

  1. Copy the default php.ini file:
sudo cp /etc/php.ini.default to /etc/php.ini
  1. Edit /etc/php.ini and uncomment this line to enable xdebug (not essential, but recommended):


Apache too comes with Mac OS, so again, no need to download and install it. Its configuration, however, is a little more complex, but nothing scary. The described configuration will provide a special Apache “sandbox” environment for your projects. It uses the existing “Sites” directory in your Mac OS home directory.

  1. Create a subdirectory in this directory for each of your projects, ensuring that the directory name does not contain any characters that would be illegal in a URL. Within each of these subdirectories create another subdirectory called “web”; this will be become the web root of each project. The extra subdirectory is in case you wish to use a framework in your projects which may keep some of its files outside of the web server root (Symfony is a good example of this).
  2. Create a subdirectory called “logs” in your “Sites” directory; Apache will maintain two log files, access and error, for all the sandbox sites.
  3. Enable PHP5 with Apache by editing /etc/apache2/httpd.conf and uncomment the following line:
LoadModule php5_module libexec/apache2/libphp5.so
  1. Change the user and group to your username and “staff” respectively, also in /etc/apache2/httpd.conf:
User sbf
Group staff
  1. While still in /etc/apache2/httpd.conf, find the following configuration and change “Deny from all” to “Allow from all”:
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
  1. Create and edit /etc/apache/users/user.conf with the following, changing “sbf” to the username:
<VirtualHost *:80>

    ServerName dev.local
    DocumentRoot /Users/sbf/Sites/

    RewriteEngine on
    RewriteLogLevel 1
    RewriteLog /var/log/apache2/rewrite.log

    # sites in the format http://[site].dev.local
    RewriteCond %{HTTP_HOST} ^[^.]+\.dev\.local
    RewriteCond %{REQUEST_URI} !^/error/.*
    RewriteCond %{REQUEST_URI} !^/icons/.*
    RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
    RewriteRule ^([^.]+)\.dev\.local/(.*) /Users/sbf/Sites/$1/web/$2

    # Logging
    CustomLog /Users/sbf/Sites/logs/sandbox.access.log combined
    ErrorLog /Users/sbf/Sites/logs/sandbox.error.log

  1. Restart Apache:
sudo apachectl restart

Then, for each of your sites, add an entry in /etc/hosts for with the format “name.dev.local” pointing to, where name corresponds to a subdirectory in your “Sites” directory. Don’t forget that the public subdirectory of each site is assumed to be “web”, so make a symlink to this if the framework you use has a different convention.

You should then be able to access each of your sites from URLs using the convention http://name.dev.local/ – where “name” again is a subdirectory within your “Sites” directory.

I’ve tested this setup procedure and It Works For Me [tm]. If, however, it doesn’t quite work for you as described, please let me know where you’re going wrong and how, if you were able, to resolve it, and I will update these instructions accordingly.


Call centre HUD for Asterisk

At work every fortnight or so we hold what we call Evenings Of Code. The company buys the development team pizza and beer and in exchange we work on projects and ideas that are of special or particular interest to us, that the company would benefit from, but that the company doesn’t really need at the moment and so normal weekday work time cannot be allocated to it.

My recent project has been to create a HUD (Heads-Up Display) for the call centre. I’m particularly suited to do this out of those in my team because I have quite a lot of experience with Asterisk, the popular open-source PBX, on which the company’s telephone system is based. The system, designed for a 1080p display (it’s not yet decided whether we’re going to go for a plasma or a projector yet), uses caller details records (CDRs) and the Asterisk Manager system to gather statistics on the day’s calls. It’s not quite realtime, but the key queue statistics from the Manager are updated every five seconds and the cumulative statistics based on the CDRs since midnight every 20 seconds.

A script runs constantly in the background during the working day (8.00am to 8.00pm) to perform the updates, which saves the results in a database table. The HUD itself is then loaded in a browser and uses AJAX calls every five seconds to read the contents of this table. This will allow multiple instances of the HUD to run without each hammering the CDRs and the Manager. At the moment, as it’s in testing, it’s being loaded into web browsers by certain staff members, and so when it initially loads it loads quarter-size. When we finally put it up on the wall we would then hover over the top right corner and an option will appear to enlarge it to full 1080p, basically by doubling the values in key CSS properties.

It looks slick too. Because it uses AJAX there are no page loads, you would expect nothing less in this day and age. If a digit changes after retrieving an update then the old digit is faded out before the new digit is faded in. If a digit doesn’t change between updates it obviously remains static.

We’re now trying to ascertain whether my algorithms for calculating the statistics are accurate at the moment by using a bit of manual record keeping on the part of the cell centre staff, who have been asked to record the number of calls they are taking per day for a week or so, independently of the records on the PBX. I’m confident that I’ve got it right, however, and actually quite pleased the information that I have been able to calculate given that Asterisk CDRs aren’t all that great to work with.

Assuming the project gets full approval following testing my intention is to get it running on a Raspberry Pi, which can be strapped to the back of the screen or on top of the projector, or indeed easily hidden in the ceiling in either case. Given that modern screens and projectors come with USB ports they will even be able to supply power to the Raspberry Pi. This means that the screen or the projector, whichever is chosen, represents the largest cost of the project as the Raspberry Pi eliminates the need to dedicate a whole PC for the purpose. My research indicates that the Raspberry Pi is capable of running Google Chrome, so that’s all good.

Screenshot of the system during a quiet period (no calls in the queues)


London 2012 Olympic Games

After a seven year journey, arguably more if you believe that it was all inspired by the success of the 2002 Commonwealth Games in Manchester, the ultimate sporting tournament has now come and gone from London, Paralympics notwithstanding. For most of us this was a once-in-a-lifetime event, which had not happened for 64 years previously and may well not happen again for a similar amount of time. I thoroughly enjoyed it from start to finish, much much more than I expected to. For a long time I was very cynical about the whole thing, believing that Britain would, like it does so often with things, embarrass itself my making it “a little bit shit”, and that hosting the Olympic games was an extravagance that an already disproportionately privileged capital city simply did not need, but I am happy to stand proven wrong. I didn’t watch the Olympics at all before Beijing, not even the ceremonies. I watched some of Beijing, but with London I had it on the television at every opportunity.

Opening Ceremony

Everyone said that the opening ceremony couldn’t possibly top that of the Beijing games in 2008, but nobody really agreed on which metric should be used to compare the two. The Beijing ceremony was an over the top and ostentatious display, designed deliberately to be virtually impossible to follow in terms of expense and scale. Only China ever could and would do that. London’s opening ceremony, however, was not inferior to this spectacle in my opinion. It told the world the story of how Britain came to where it is now in a hugely tender, original and humorous way and I think that Danny Boyle created an utter masterpiece. Certainly, he deserves a knighthood much more than Gary Barlow does for organising a pop concert on the Queen’s driveway. I was  in tears by the time the five forged rings rose up, and I was set off again when the cauldron was lit. I thought both parts were utterly beautiful. I’m just a big softy, really.

My own silly sentiments aside, I think the best review of the opening ceremony came from Sarah Lyall in the New York Times, who writes:

“Britain presented itself to the world Friday night as something it has often struggled to express even to itself: a nation secure in its own post-empire identity, whatever that actually is… It was neither a nostalgic sweep through the past nor a bold vision of a brave new future. Rather, it was a sometimes slightly insane portrait of a country that has changed almost beyond measure since the last time it hosted the Games, in the grim postwar summer of 1948.”

However, not all was good with the opening ceremony. It was all absolutely brilliant, right up until the very last moment when they wheeled out Paul McCartney. Up until that point the underlying theme and message of the London games, “Insipire a generation”, had been rammed home, since this was the premise on which London was originally awarded the games. We had just seen seven young athletes light the cauldron instead of the usual washed-up old sports star that other countries normally use. They did this with torches literally passed on to them by established Olympians, all heralding and symbolising the start of a new generation. They followed this by pushing out Paul McCartney, an old man from the past who can’t sing properly any more and whose face is falling off his head, to sing a frankly boring song that the world has heard countless times. I can only think that his segment was included to please a United States TV audience. It was very obviously out of place, a huge and awkward elephant in the room, and I think it was a mistake. Critically, however, aside perhaps from not relieving the idiot that is Mitt Romney of his ticket to the ceremony and giving it to a soldier, it was the only mistake.

In case you were wondering, Mitt, this “tiny island that makes stuff nobody wants” produced Sir Tim Berners-Lee. He invented the World Wide Web. Just thought you ought to know. Danny Boyle thought you ought too.

Events and medalists

God save the King

The success of securing the games as hosts is one thing, but it was only half the story of Great Britain’s success at London 2012, and arguably the easier half. More important is the outstanding performance by Team GB. Great Britain won the most medals for 104 years, and the 1908 games don’t really count as that was during the Empire days, meaning that the medal haul was skewed by the fact that we owned a third of the world and its athletes. The medals came thick and fast, allaying any fears that “home games nerves” might affect performance. I have such huge admiration for Olympic athletes, they train all day every day for years at a time and aren’t interested in the glamour, wealth and fame that other sporting occupations readily provide. With this in mind one questions why David Beckham seemed to get so much attention before and during the games.

The congratulations also go beyond Team GB of course. World records seemed be being broken every day by athletes from all around the world. The bar was set very much higher than it was in Beijing. Rebecca Adlington only secured a bronze medal this year, despite swimming faster than the time that gave her a gold in Beijing. Michael Phelps smashed to smithereens the longstanding record for the most number of Olympic medals won by one person previously held by the Soviet Union.

Closing Ceremony

The closing ceremony always plays second fiddle to the opening ceremony, but for good reason. It is supposed to be a more subdued affair, formally closing the games with the extinguishing of the Olympic flame and the passing of the flag to the next host city. Aside from these standard features in any closing ceremony programme, the rest of it left me rather underwhelmed. Again, as with the Jubilee concert in June, they wheeled out more of the same usual suspects that we’ve seen time and again, including George Michael, an ageing drug-addled convicted drink-driver who cynically used the event to promote his new single. I don’t really think that he is an appropriate person to “inspire a generation”. I also thought that we’d all got over The Spice Girls 15 years ago, apparently not. The whole thing felt like a Brit Awards ceremony from the 1990s.

I watched the closing ceremony in 3D, as it was one of the few programmes that are part of the BBC’s trial of 3D broadcasts this year. I would have watched the opening cermony in 3D too, but there were three other people in the room and only two pairs of glasses. Whilst I enjoyed the 3D broadcast I did not understand why the BBC used different commentators to those on BBC1. I would have preferred Huw Edwards, instead of whoever it was who was on BBC HD, whose sidekick could barely string a sentence together. I would also suggest that the BBC HD commentator, who claimed that the closing ceremony was the first time “anyone outside Brazil” had seen the Rio 2016 logo, does not yet have access to Google Images and should probably do something about that.

Controversial issues

Despite the success of the games it would be odd if I didn’t mention some of the more controversial issues surrounding them. I won’t dwell on them too much, relatively speaking at least, but these are the ones that annoyed me the most (there are more, but less annoying):

  1. Cost: London 2012 ended up costing more than four times the original budget put forward by the former Labour Olympics Minister Tessa Jowell, an eye-watering £9,100,000,000. Despite this, LOCOG triumphantly announced that they had brought it all in “under budget” by a few hundred million and Tessa Jowell was made a Dame in return for underestimating the cost of hosting the games by a factor of four.
  2. Sponsorship and brand protection: Make no mistake, I fully appreciate and understand the requirement for sponsorship from large corporations with deep pockets for the Olympic games, even if that does mean ridiculous things like peddlers of cheeseburgers and sugary drinks getting exclusive rights to distribute both in the Olympic park. However, corporate sponsors didn’t fund the vast majority of the games, tax payers did, and if it was supposed to be “the peoples’ games” (the “people” being its major financial benefactors) then if the people wanted to put up a representation of the Olympic rings in their shop window that wasn’t approved/sold by LOCOG, or put that absurd 2012 logo on their blog then they damned well should have been able to without fear of going to jail.
  3. Tickets: I didn’t apply for any tickets, chiefly because I didn’t like the idea of LOCOG helping themselves to random sums of money from my bank account at random times for all or a random selection of tickets for which I virtually had to beg online. If any commercial company tried to sell tickets or any other type of product using this model they would be immediately closed down by trading standards and no bank would ever provide them with merchant services. I saw no reason why LOCOG should have been exempt from this. Even setting those issues aside, I simply didn’t have a few hundred quid to drop on tickets to an event that I probably wouldn’t have been interested in, or a few thousand for a ticket to an event that I might’ve actually enjoyed. Home games or not, the £700 I spent on my television represented much better value for money and I was able to see many more events from the best sofas in the house. Had I bought tickets I would have also been even more aggrieved than I was when I saw all the empty seats which Lord Coe then gave to students and teachers, instead of nurses and firefighters.
  4. Bus drivers: These greedy arseholes demanded and were awarded an extra £500 just for turning up for work during the games, and yet despite this were still unable to not kill anybody.


I truly hope that the London games has the impact on the country that has been promised. This isn’t just because I want to see value for my tax money, but because I actually do. The Olympics is arguably the largest and most important regular worldwide event, involving more countries than are members of the United Nations, all of whom come together for two weeks every four years for the same purpose and goal. If that doesn’t have some sort of lasting impact on a country that hosts it then what will?

Could someone of my age possibly see the Olympics on home soil again? Possibly, but not especially likely. While it is true that there were only 12 years between the 1984 Los Angeles and 1996 Atlanta games the United States is not typical in terms of size and wealth, and so this statistic is arguably skewed. More or less a “double award”, this would have also impacted New York’s 2012 bid. If Madrid get awarded the 2020 games it will mean that 28 years will elapse between Barcelona in 1992 and those games, which is a little more realistic but not so long that most people who lived through the 2012 games in London would not get to enjoy, for the sake of argument, a re-run in 2040.

Maybe by then I’ll have saved up enough for a ticket to the opening ceremony.

The floozy in the jacuzzi gets a good view of the big screen in Birmingham’s Victoria Square