So you found yourself in need of a development server (or maybe a regular production server) on your Mac… Well, good for you, because your mac can do it all. I found myself in need of it as well and wanted a stable Apache2/PHP5/MySQL installation with the PHP SVN PECL module installed. (because I want to fool around with our SVN server :) )
I can tell you 4 ways of getting a real, life ‘n kickin’, web server on OSX.
1. Use MAMP
MAMP is probably the least painless but also the least compatible. I’ll tell you the pro’s and con’s.
- Easy to install when used out of the box
- Offers choice between PHP 5.2 and 5.3
- Comes with a control panel to restart MySQL and/or Apache
- Offers a PRO version to allow Virtual Host configuration
- Does NOT play nice with the built-in Apache web server (disable it and use MAMPs server)
- Does NOT play nice with the built-in PHP (You will need to do some configuring to get OSXs built-in PHP to work with MAMPs MySQL)
- Configuration of the non-PRO version of MAMP is a joke; there is none. Use VirtualHostX to do your heavy lifting.
- The PECL SVN extension I needed is a pain to install, numerous attempts failed
MAMP PRO is a bit better but it’s commercial.
- Built-in Virtual Host panel
- In my attempts, the Virtual Host configuration was not saved, not in Native Apache mode, not in MAMP Apache mode and not even in Manual-select-paths-to-config-files-mode.
Advice on MAMP:
Use it when you have no choice, discard and use the options below for a more stable environment. And MAMP Pro?? not worth the money, use the free version and buy VirtualHostX instead.
2. Macports Apache/MySQL/PHP
This is a bit more tricky to set-up. There is some planning involved and you can find decent guides on the internet everywhere. Just google it.
- xcode (Apple, Free, see the App Store application on your mac)
- macports (free)
- Use the guide in the previous link to install it.
- It works like a charm; all files are placed in /opt so no system parts are touched. Macports will adjust your system config to use the newly installed software
- All latest software built for your system
- Software that uses the built-in Apache/PHP other than via the webserver will need configuring to use the Macports version
- The SVN PECL module? no dice. Not available in Macports – or so it seems after 48 hours of googling (not all in one day :P )
3. A hybrid version
Just use MySQL from Macports, and the rest from OSX
- Easy install; one package and done.
- In my case PHP 5.2 would not build from Macport or did build and produce segmentation faults, so just use the built-in Apache and PHP.
- Still need to tell PHP where to find your database server socket.
- Still no SVN support
And indeed, you still have to use a program like VirtualHostX to set-up virtual hosts.
4. My favorite; use the built-in Apache and PHP and MariaDB for a super-fast 100% MySQL compatible database.
- Super fast Database (YES, it is faster than MySQL and with Oracle holding the code, MySQL will probably not stay free forever.)
- Very easy to install with this great guide – much easier than MacPorts in my opinion. (follow the MariaDB instructions and skip the ‘APC and other PECL modules’ section)
- after installation, a Shell commandwas all I needed to do to get SVN included.
pecl install svn
And again, you will still need VirtualHostX (or similar) to maintain your virtual hosts
Ow, and a final note;
When trying out VirtualHostX and you find your hosts don’t work? Downgrade to version 2.x of VirtualHostX, it works like a charm!
Ow, p.s. don’t forget to grant access to your databases.