Alex Hardy


Hello there!

Archive for December, 2007

A quick guide to installing a local PHP MySQL development server on Mac OS X

Friday, December 21st, 2007

Mac users are sensitive little souls. Artistic types. We love our beautifully designed computers and software, but poking around in the guts of our operating system doesn’t come quite as naturally to us as to our PC using friends.

Sometimes though that can be a very worthwhile exercise, such as installing a dev server. Perhaps you have a laptop, and need to be able to work or present when you don’t have internet access (eg: while travelling). Here’s how…

Good news, everyone!

The Apache web server and PHP are already installed as part of Mac OS X and only need to be turned on. The MySQL database server will have to be downloaded and installed, but we’ll cross that bridge when we come to it…

This is an easier job than it used to be and doesn’t have to involve typing code into the Terminal. Marc Liyanage does a fantastic job of creating PHP installer packages if you want to keep your installation bang up to date, but for most purposes the instructions below should be sufficient.

Note: I have used Mac OS X 10.5 Leopard and MySQL 5.0.45 (the latest at the time of writing) on a MacBook Pro. I used TextMate to edit text.

Part 1 – Apache and PHP

  1. Go to Apache folder

    Start by editing the Apache config file to enable PHP. This file is hidden by default, but you can access it from the Finder’s “Go” menu. Enter /etc/apache2 and confirm to make the folder appear.

  2. Edit Apache config file

    Open httpd.conf in a text editor. Find the line that says:

    #LoadModule php5_module libexec/apache2/libphp5.so

    Uncomment it by removing the hash. Save the file (you will be asked to enter your admin password).

  3. System Preferences – Sharing

    Open System Preferences and go into “Sharing” (under “Internet & Network”).

    Turn on ”Web Sharing”. You now have an active Apache server with PHP. Test this by typing localhost into your browser. You should see the default Apache page.

  4. Turn on Web Sharing

    If you feel curious, create a PHP file with the phpinfo() function call in it to see the details of your installation.

    Place your own files in /Library/WebServer/Documents

Part 2 – MySQL

  1. MySQL Community Server

    First things first: Head on over to MySQL.com and download MySQL Community Server and the GUI Tools.

    As their names indicate, the former is the database software itself while the latter is a collection of graphical tools to make the task of administering MySQL easy for those of us that find the Terminal a bit too scary.

  2. MySQL GUI Tools

    I use an Intel Mac, so I got the Mac OS X 10.4 (x86) builds. Take care to download the most appropriate build for your computer and OS version.

    I recommend that you always use the latest GUI tools for the latest features and stability improvements.

  3. Mount the MySQL disk image and run the main package first, then install the startup item, finally the prefpane. I needed to restart before MySQL would turn on.

  4. MySQL prefpane

    Open System Preferences and go into “MySQL” (under “Other”). Tick the box to automatically start MySQL on startup.

    You can install the GUI Tools by dragging them from their disk image to your Applications folder. Nearly there now!

  5. It is crucial that you now set a password for the MySQL “root” account. Open MySQL Administrator and log into localhost with root (no password). Under “Accounts” you can assign a password to root, as well as create other database users.

    Avoid using the root account in your applications – use it only for administration.

    That’s it! You can start creating databases and coding the PHP applications that will run on them.

Recommended Reading

PHP and MySQL for Dynamic Web Sites

If PHP and MySQL are new to you, I recommend PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide by Larry Ullman. In common with other books in the series, this book gives you a solid grounding in the subject, with plain English examples.

If you are already familiar with HTML and maybe a scripting language or two, you should hit the ground running!

If this guide was useful to you or you would like me to elaborate further, please feel free to comment. I’m thinking about writing a series of how-tos in this manner and your feedback would be appreciated.

Great design is in the small details

Friday, December 14th, 2007

This makes me happy :) I’d be first to admit that my talents do not include wrapping presents. I’m rubbish at it! My attempts to cut usually end up looking like a proverbial dog’s hind leg. Maybe no more though, because I bought some wrapping paper yesterday which turned out to be the best I’ve ever found.

What was so great about it?

The reverse side of the paper had a grid of lines drawn on the back. It was easy to follow the lines with my scissors and end up with a perfectly cut sheet of paper. Brilliant. The only thing left to do was not screw up the folding…

As Robert Hoekman Jr, author of the superb “Designing the Obvious” would be quick to point out, these lines are an example of a poka-yoke (“mistake proofing”) device. Why point out someone’s mistake when you can prevent it from occurring?

Great design makes your user feel smart and empowered.

Compress Files

Thursday, December 13th, 2007

Compress Files

If you work on a Mac and make zip files to share with Windows users, you’ll know what a nuisance it can be when invisible files from Mac OS X find their way in.

Resource forks and ._DS_Store files (which store data such as icons, associations and view preferences) are redundant and visible in other systems, and not only confuse users but inflate the zip file with unnecessary data. It becomes a manual task (on a Windows PC) to remove these files.

So I thought I’d share a little app I discovered the other day: Compress Files by Apimac. Two little checkboxes instruct it to remove these files and you have a nice clean zip ready to send. The $9.95 asking price is nothing compared to how much time it will save you.

The Blog Council

Thursday, December 13th, 2007

A new website has been set up called The Blog Council. In the words of the site:

The Blog Council is the community for large companies’ blogs. It is a private group for this unique group of bloggers to share best practices and new ideas.

The response has been mixed. Greg Storey is right to question the wisdom of discussing an inherently public medium in private, but I think it’s a positive step.

If you blog about your cat that’s fine, but speaking on a professional level makes matters more complicated. You should maintain a dignified and constructive tone even if you only represent yourself. It’s not beneficial to rubbish others. It’s downright foolish to say disparaging things about your colleagues or company if you wish to remain employed now and in future.

I don’t speak for the Foundry, but I have a responsibility to them. As I show their work in my portfolio I am obliged to present it in an appropriate way. I should answer or refer questions, criticisms or employment inquiries that come to me. I should promote their work and activities in an honest way.

Working for a company whose sole preoccupation is the building of brands, I cannot ignore the marketing implications. The only thing more frightening to companies than being seen as behind the times would be to embarrass themselves. Sony have been busted time and again for trying to create artificial buzz around their products. Instead of improving your image, you earn widespread ridicule.

The internet alters the consumer’s relationship with the brand. The aspirational values (e.g. youth, cool, affluence, sexiness etc) that money and time have been spent to cultivate meet the reality of what people think of the company behind it.

Brand perception can no longer be just pushed at the audience through advertising channels when a bad review can sabotage a purchasing decision. This puts pressure on companies to be less aloof. You can’t silence public opinion, but you can change it by listening and improving your products, services and message.

If you blog directly on your company’s behalf, your responsibility is crucially important. You are an ambassador for your company. There are already good examples to be found: The IEBlog is candid, constructive and has engaged with high profile community members such as Molly Holzschlag.

I would hope that these private sessions will be few, and part of a first stage where the members of this new community compare notes before they open themselves out. Some things you can only learn how to do by doing them.

simpleContact 1.2 is available

Monday, December 10th, 2007

If you arrived here via a certain update link you’ll already know what this post is about! I’ve released simpleContact 1.2. This is a maintenance release, which doesn’t bring radical changes but improves compatibility and existing features.

New additions

  • User options page to edit your email address and password
  • Paging in the inbox (the control appears when you have over fifty messages)
  • Email addresses in the mailing list and recipients pages are now mailto links
  • You can remove someone from the mailing list inside the message view
  • “Remember me” checkbox at login (uses a cookie)

Tweaks and fixes

  • The function that cleans submitted data now strips out HTML markup
  • Dates and times are now formatted in a more clear and international manner
  • Fixed for certain server configurations where include paths could break
  • The email sending script correctly formats line breaks and quotemarks
  • Update check tries again with cURL if fopen is disabled
  • password.php updates the sc_admins table when a password is reset
  • Formatting of received messages is improved
  • The “simpleContact” name now links to the inbox or the login page
  • General copy and layout improvements

This will be the last version before the release of simpleContact Pro, which I will start work on in the new year. The applications will exist side by side, with an upgrade path for those that want the advanced features of the Pro version (e.g. custom fields). I also have many ideas up my sleeve for the free version…

But all that’s for another day! Today, head on over to my downloads page and grab version 1.2. I hope you find it useful!

Downloads RSS feed

Friday, December 7th, 2007

I’ve made a new RSS feed to support the ongoing changes in my website. Instead of a dedicated feed for each project, I’ll have one Downloads feed, um, to rule them all.

I’ll remove the simpleContact blog category and feed in the new year. If you are already subscribed to the simpleContact feed, please subscribe to the new feed.