Monday, May 4, 2009

Installing Apache, PHP and MySQL on OS X Leopard for the lazy


Here's a simple tutorial to get a running server and database on OS X Leopard. You'll need to download MySQL and Sequel Pro (a nice alternative to phpMyAdmin).

1. Open terminal to turn on PHP.
> Open server configuration file.
   [sudo pico /etc/apache2/httpd.conf]

> Find #LoadModule php5_module.
   [Ctrl + W, LoadModule php5]

> Uncomment by deleting #.
   [Backspace]

> Save changes.
   [Ctrl + O]


2. Install MySQL and change php.ini file.
> Install all packages in the *.dmg file.
> Copy over the default php.ini to actual file.
   [sudo cp /etc/php.ini.default /etc/php.ini]

> Open php.ini file.
   [sudo pico /etc/php.ini]

> Find mysql.default_socket.
   [Ctrl + W, mysql.default_socket]

> Change value to /tmp/mysql.sock
> Save changes. [Ctrl + O]

3. Install Sequel Pro. This will let you manage your MySQL database with ease. The default values to connect to your database are...host:localhost, user:root, password: [blank].

All right, you're set! Now let's turn on Apache and MySQL.
> Go to System Preferences -> Sharing -> check Web Sharing. (This turns on Apache)
> Go to System Preferences -> MySQL -> click Start MySQL Server button.

The default directory for your server lies in /Library/WebServer/Documents. If you want to change this, you'll need to edit the DocumentRoot variable in your server configuration file.

Just to be thorough, to view your site, just type localhost into your address bar, and voila!

No comments:

Post a Comment