After every change you make to the Apache or PHP config files you will need to restart the Apache web server.
By default PHP is disabled on OSX, so we'll need to turn that on.
mate /etc/apache2/httpd.conf
Head to line #115 (line number may vary) and uncomment (remove the #) the line that says
LoadModule php5_module libexec/apache2/libphp5.so
Save the file. Since this file requires an admin's approval to edit it, you will be asked to enter your password.
By default, the Snow Leopard version of PHP doesn’t have the timezone set. This will give you errors if and when you use the date() function. To fix this you need to copy php.ini.default
to php.ini
and add your appropriate timezone.
cp /etc/php.ini.default /etc/php.ini
mate /etc/php.ini
Head to line #992 (line number may vary), drop the preceding semi-colon and add your timezone name. When you're done it should look something like this:
date.timezone = America/Chicago
Before we can use mySQL we need to point PHP to the correct place. In the php.ini file, change line #1213 to:
mysql.default_socket = /tmp/mysql.sock
Open httpd.conf
and uncomment line #468 (line number may vary) which reads Include /private/etc/apache2/extra/httpd-vhosts.conf
, then save.
mate /etc/apache2/httpd.conf
While we're in there let's also change line #214 to read AllowOverride All
.
Now we need to open /etc/apache2/extra/httpd-vhosts.conf
and comment out the virtual host blocks and add this virtual host block.
mate /etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot /Users/youruser/Sites/yoursitefolder
ServerName yoursitesname
</VirtualHost>
Open /etc/hosts
and add 127.0.0.1 yoursitename
so that your host name resolves to the site specified. You will need to add a new line for each Virtual Host you have set up where yoursitename
matches the name chosen name in the VitrualHost block.
mate /etc/hosts
Bonus: Simple new site creation steps for WordPress
mate /etc/apache2/extra/httpd-vhosts.conf
mate /etc/hosts
curl http://wordpress.org/latest.tar.gz | tar -zxv --strip 1
Sources:
sudo apachectl start