mkaz.com home photography web dev about
Setting up MOXAMP Platform
Mac OS X, Apache, MySQL, PHP
Marcus Kazmierczak
November 27, 2000

This page walks through the setup of Apache, PHP and MySQL for developing web applications on Mac OS X, a great development platform.

Setting up Mac OS X

If you haven't already, it is recommended you upgrade to version 10.2, also known as Jaguar. With 10.2, Apple introduced new features and fixed many issues. Jaguar also moves Mac OS X closer to other Unix-type systems with file locations and operability.

Developer Tools - You definitely should install the developer tools. This gives you all the standard development tools one would on a Unix box, such as a compiler (gcc), libraries and other tools. The developer tool disk should come with your OS or you can download it from Apple Developer Connection (registration required)

Like anything, there's more than one way of doing it. The following is the way I set my developer station up. It is one of the easier and less intrusive ways and should work with out-of-the-box Mac OS X installs.

Note: You do pay a small price for the ease of setup. It relies heavily upon others maintaining the packages. So it is not necessarily the most flexible and up-to-date system. However, this is rarely a problem and you'll spend more time developing then system administration.

If you would like a more technical and hand compiled setup, giving you complete control over all options. You can refer to my Linux install instructions the process should be similar for Mac OS X.

Setting up Apache

Mac OS X comes with an installation of Apache (version 1.3.27)
The httpd binary can be found at /usr/sbin/httpd
The configuration files are at /etc/httpd/

Apple ships Apache with dynamic module support compiled in. They also include all modules as options you can configure in the httpd.conf file. So adding new functionality is simply downloading a new module and adding it to the config.

NOTE: If you are unfamiliar using the Terminal (command-line), check out Learning the Mac OS X Terminal tutorial series at O'Reilly.
Setting up MySQL

The packages I use for MySQL and PHP are setup by Marc Liyanage, a guy in Switzerland generous enough to make these available from his site (http://www.entropy.ch/)

On his site, Marc includes great step-by-step instructions on how to download, install and setup each of the packages. Be sure to follow the correct instructions for your OS X version. MySQL Package and Instructions

Go ahead download, install and setup MySQL following his instructions. Be sure to setup the root password.

After you have that all setup, you can create a "webuser" which PHP will use to access MySQL. MySQL manages it's users via a database table in MySQL, database name "mysql" and table name "user".

$ mysql -u root -p
Enter password:

-- select what database to use
mysql > use mysql;

-- show what's in the user table
mysql > SELECT * FROM user;

-- insert new user in table
mysql > INSERT INTO user
   > (host, user, password,
   > select_priv, insert_priv, update_priv, delete_priv)
   > VALUES
   > ('localhost', 'webuser', password('yourpwd'),
   > 'Y', 'Y', 'Y', 'Y');

-- reload privileges
mysql > FLUSH PRIVILEGES;
mysql > exit;
NOTE: While in the MySQL client, commands end with a ";" you can hit enter without executing the command unless a ";" has been entered. So the above breaks down into multiple lines for ease of displaying on the web. The commands can be entered all on one line.

For detailed information regarding privileges and account management, please read the MySQL Manual, Sec 4.3 - User Account Management

After users are setup MySQL should be all ready to go.

Setting up PHP

PHP is very straight forward to install since it is just an add in module to Apache. Marc Liyange's site has the package already pre-compile with built-in MySQL support which makes it even easier. Please follow Marc's setup instructions on his site at: PHP Package and Instructions

To see how to write a web application using this setup check out my Web Database Tutorial.


Related Links