New Mac OS X 10.5 Leopard comes with new versions of Apache and PHP (
Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.7l DAV/2 PHP/5.2.4), so it is quite easy to setup a MAMP server. Sure there are other ways to do the setup: You can build Apache, MySQL and PHP from sources, you can use MacPorts or you can use pre-build packages like MAMP or XAMPP. But in my opinion, because Apache and PHP are already installed, they are easy way to go and will minimize you work.
To enable pre-installed PHP, you have to edit httpd.conf file:
sudo vi /private/etc/apache2/httpd.conf
And uncomment next line:
LoadModule php5_module libexec/apache2/libphp5.so
If you want to make other configuration changes, for example define virtual hosts, it’s better to use user’s configuration file:
sudo vi /private/etc/apache2/users/[username].conf
After making changes, restart Apache aka Web Sharing. Go to System Preferences > Sharing and unselect and select again Web Sharing. That’s it. Now you have the Apache and PHP running. If there are any problems, you can examine the Apache error_log. Go to Console > /var/log > apache2 > error_log.
If you want to make changes to php.ini, do the following. Copy php.ini.default to php.ini:
sudo cp /private/etc/php.ini.default /private/etc/php.ini
And to make changes:
sudo chmod 644 /private/etc/php.ini
sudo vi /private/etc/php.ini
sudo chmod 444 /private/etc/php.ini
After making changes don’t forget to restart Apache.
MySQL is a little trickier. It is not pre installed in OS X and in my opinion easiest way is to use binary from MySQL.com. So, download the current version, which is mysql-5.0.45-osx10.4-i686.pkg at the moment and install it. Then install MySQLStartupItem.pkg and copy MySQL.prefPane to OSX/Library/PreferencePanes. It seems to be that current versions preference pane is not quite compatible with OS X 10.5. It shows if the server is running or stopped, but you can’t star or stop with it. MySQL starts when the OS starts, but you can start or stop it manually from console:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
MySQL with default settings use socket in /tmp and pre-installed PHP presumes it to be in /var/mysql, so you have to update the location in php.ini:
mysql.default_socket = /tmp/mysql.sock
Perhaps you could also use a symbolic link from /var/mysql/mysql.sock to tmp/mysql.soc. MySQL GUI Tools are also working nicely with new OS X 10.5.
Mac OS X 10.5
No you should have a MAMP server running nicely. If you want to make host name changes – for example you can use different names for localhost to take advantage Apache’s virtual hosting – edit hosts file:
sudo vi /private/etc/hosts