Apache/MySQL Set Up Instructions for Snow Leopard
Step 1 - Creating your site
1. Type the following in Terminal:
Code:
cd /Users/yourname/Sites
mkdir mysite.com
cd mysite.com
printf "My awesome site" > index.html
Step 2 - Setting up Apache:
1. Open /etc/apache2/httpd.conf in a text editor
2. Change
Code:
#Include /private/etc/apache2/extra/httpd-vhosts.conf
to
Code:
Include /private/etc/apache2/extra/httpd-vhosts.conf
3. Open /etc/apache2/extra/httpd-vhosts.conf in a text editor and at the bottom add:
Code:
<VirtualHost *:80>
<Directory /Users/yourname/Sites/mysite.com>
AllowOverride All
</Directory>
DocumentRoot /Users/yourname/Sites/mysite.com
ServerName mysite.local
</VirtualHost>
Step 3 - Setting your hosts file
1. Open /etc/hosts in a text editor
2. Add the following as it relates to your ServerName in Step 2
3. Start Apache from Terminal:
4. If you see
Code:
org.apache.httpd: Already loaded
Then restart Apache:
Step 4 - Enable PHP
1. Open /etc/apache2/httpd.conf in a text editor
2. Change:
Code:
#LoadModule php5_module libexec/apache2/libphp5.so
to
Code:
LoadModule php5_module libexec/apache2/libphp5.so
3. Restart apache in Terminal:
4. Test PHP:
Code:
cd /Users/yourname/Sites
cd mysite.com
printf "<?php phpinfo() ?>" > index.php
5. Go to
http://mysite.local/index.php and if you see phpinfo then php was successfully enabled and Apache is set up.
Step 5 (optional) - Enable Error Reporting Output in Browser
This is optional but very useful if you want to know what line the PHP fails at and the associated error message. I would recommend this for testing/personal use.
1. Open /private/etc/php.ini in a text editor
2. Find the section entitled "Error handling and logging"
3. Uncomment the following directive within the section and set it to on:
4. Restart apache in Terminal:
Step 6 - Installing MySQL
1. Download the MySQL package for Mac OS X.5 (32 or 64 bits depending on your machine)
2. Install everything in the package in this order: mysql, the startup item, the preference pane.
3. Start MySQL in the preference pane.
4. Fix mysql.sock location in /etc/php.ini, replace the three occurrences of
/var/mysql/mysql.sock
with
/tmp/mysql.sock
5. Restart apache in Terminal:
That should get you running...I just recently set up my MacBook Pro and these are the instructions I put together from a host of websites.