Mac OS X 10.6 Snow Leopard comes with Apache and PHP (
Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 PHP/5.3.4), so it is quite easy to setup a MAMP server.
Sure, there are other ways to do the MAMP setup:
- Build Apache, MySQL and PHP from sources.
- Use MacPorts.
- Use development or server environment packages like MAMP, XAMPP for Mac OS X, or WebStart for Mac OS X.
In my opinion, because Apache and PHP are already installed, it’s easy way to go with them.
To enable pre-installed PHP, you have to edit httpd.conf file:
sudo vi /private/etc/apache2/httpd.conf
And uncomment the 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 with 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, because it’s not pre-installed in OS X. In my opinion easiest way is to use binary from MySQL.com. So, download the current version, which is mysql-5.5.10-osx10.6-x86_64.dmg at the moment, and install mysql-5.5.10-osx10.6-x86_64.pkg.
Then install MySQLStartupItem.pkg and copy MySQL.prefPane to OSX/Library/PreferencePanes.
MySQL starts when the OS starts and you can start and stop it from System Preferences > MySQL. You can also 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
Mac OS X 10.6
No you should have your MAMP server running nicely. If you want to make host name changes – for example if you use different hosts in localhost to take advantage Apache’s virtual hosting – edit hosts file:
sudo vi /private/etc/hosts