OS X 10.8 comes with Apache 2.2.22 and PHP 5.3.15 (with Suhosin).
These issues are easy to fix though, lets fix them one at a time.
If your work is going to end up on a case-sensitive system like Linux, it’s a good idea to work on a case-sensitive filesystem for development to avoid problems. The filesystem on OS X by default is case-insensitive HFS+.
You can install OS X on case-sensitive HFS+, but it’s not recommend.
And that’s it.
/Volumes/code is now a case sensitive oasis for code. Remember,
If you named your partition something different, the path will be something
Link that volume to your home folder with
ln -s /Volumes/code $HOME/code
Now you can just treat
~/code as your code folder
Download your preferred version of PHP from php-osx.liip.ch. For PHP 5.4 the required command is
$curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4
Read the page though, because there are some gotchas!
1. You’ll want to set your path to be able to use PHP from the command line
2. You’ll want to set
date.timezone to UTC or your local timezone
When I go to
http://project.dev.terite.com, I want Apache to serve
/Volumes/code/project/public. This is possible to do with the version of
Apache 2 that comes with 10.8 via mod_vhost_alias
To make sure apache is loading the vhosts configuration file, open up
/etc/apache2/httpd.conf and make sure
is uncommented. Then, add the following to that vhosts file:
<VirtualHost *:80> ServerName localhost.dev.terite.com ServerAlias *.dev.terite.com VirtualDocumentRoot /Volumes/code/%-4+/public </VirtualHost>
VirtualDocumentRoot, that number is the part of the host from
the right. If you want to set up your projects under $project.dev, your
VirtualDocumentRoot line would have to be
And then restart apache to get those changes loaded.
$sudo apachectl restart
And, there’s one more step, pointing that domain to your machine. The easiest
way is to add entries to your
/etc/hosts file, but wildcards are not
supported, so you need an entry for every project.
127.0.0.1 project1.dev.terite.com 127.0.0.1 foo.dev.terite.com 127.0.0.1 bar.dev.terite.com
Because I chose to use a domain I control, I can just add DNS wildcard DNS records to get this to work. I want to add 2 DNS records for terite.com
If you don’t control a domain, or want a short url like $project.dev, you have the option of setting up local DNS. This guide may work, I haven’t tried it myself. Watch out! OS X uses the .local TLD(top level domain) for Bonjour, so you shouldn’t use that like the guide shows, as it may cause problems for you.