I’ve avoided upgrading to Snow Leopard for ages for a number of reasons:
- didn’t want to spend ages re-setting up all my ports, I’ve heard SL creates a havoc
- wanted to maintain java apps that stop working in SL, like Zend 5.5 (it may be old but still has the best debugger around)
- wasn’t crazy about tinkering with my Cocoa dev environment
Finally I was forced to upgrade, in a panic in fact, as it’s the only way to build iOS apps for iPhone and iPad for version 4 or later. And since the iOS 4 update broke a lot of our 3.1.3 apps, I had to get fixes out asap.
So what’s involved? Well on the database side, forget about downloading the dmg for MySQL, it’s poorly setup. And forget about globally upgrading your ports, the various approaches suggested here and here simply don’t work.
Unfortunately you have to take the advice on the official Macports page and uninstall everything, then selectively re-install the ports you want. The suggestion labelled “Automatically reinstall ports” refers to a script that collapses almost instantly when it fails to find Tcl libs which certainly don’t exist in my bog standard ports setup.
So one thing you need to keep in mind is to reinstall your ports with the +universal option which specifies 32 and 64 bit architectures will be accommodated.
For a basic PHP+Apache install this page has some good suggestions but is not up to date. And you need to go herefor advice on installing MySQL, which obviously needs to be done before you install PHP. I’ve summarise the steps required here:
Install apache as follows:
sudo port install apache2 +universal
Then run the following, as advised, to get it to startup automatically after reboots:
sudo port load apache2
Just installing apache installed 16 ports including all the deps. For tweaks the config the file is here:
To get the ball rolling with MySQL, the following:
sudo port install mysql5 +universal
Then you need to issue you a
sudo port install mysql5-server +universal
which just takes a few secs and the server is setup.
To start the server on reboot do
sudo port load mysql5-server
and if you wanted to setup a new db from scratch you could issue
sudo -u _mysql mysql_install_db5
If you want to change any of the configuration the file is here:
Now that you have your Apache and MySQL installed, it’s time to install PHP and link to them:
sudo port install php5 +apache2 +universal
To enable PHP in Apache, run
/opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
then add the PHP modules you want after:
sudo port install php5-mysql
Then, to get MySQL working with PHP you need to edit /opt/local/etc/php5/php.ini and set
mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket to /tmp/mysqld.sock
And that should do the trick!