Posted in: PHP/MySQL, Apache
Just posting this to keep for reference and maybe it will help someone too. I had to do this on a new MBP this AM. Quick and dirty to do list for getting PHP/Apache/MySQL and Virtual Hosts configured on a Mac running Leopard. This article assumes you are on Leopard (OS X 10.5) and already have MySQL installed.
Step1: Enable PHP
sudo pico /private/etc/apache2/httpd.conf
Uncomment # LoadModule php5_module libexec/apache2/libphp5.so
If you need Virtual Hosts uncomment # Include /private/etc/apache2/extra/httpd-vhosts.conf
If you want to change the default root folder for serving pages e.g. to your Sites folder change The DocumentRoot (Around line 161) to /Users/yourusername/Sites and the <Directory> (Around line 190) to the same.
Save and exit httpd.conf
Step 2: Add Virtual Host
sudo pico /private/etc/apache2/extra/httpd-vhosts.conf
Append new record to the hosts file:
NameVirtualHost siteName *:80
<VirtualHost *:80>
ServerAdmin admin@email.com
DocumentRoot “/Users/userName/Sites/siteName”
ServerName siteName
ServerAlias siteName
ErrorLog “/private/var/log/apache2/siteName.com-error_log”
CustomLog “/private/var/log/apache2/siteName.com-error_log”
</VirtualHost>
Step 3: Configure MySQL
sudo pico /private/etc/php.ini
If no file exists copy php.ini.default
cp /private/etc/php.ini.default /private/etc/php.ini
Change mysql.default_socket = to mysql.default_socket = /private/tmp/mysql.sock
and
mysqli.default_socket = to mysqli.default_socket = /private/tmp/mysql.sock
Step 4: Restart Apache
sudo apachectl graceful
I think that about covers it, if I missed anything or something seems off please let me know.
Bill said:
This just saved me a bunch of time. Cheers!