Easy and Elegant (?) Snow Leopard Web Development Platform

I'm getting started with designing a new Drupal theme using Zen. However, a first step needs to be to set up a development environment on my Mac, so I can use local tools and not keep messing with a production (glorified hobby) server.

I initially tried the built-in Apache server in Snow Leopard, but that was no good - the bundled PHP was missing too many extensions. And rather than hack together a mix-and-match of Darwin ports, etc, I looked for another option. MAMP looks to fit the bill perfectly: Apache, MySQL, PHP - and all installed in a self-contained directory so they can be easily removed. Plus, no messing with the bundled server. And it comes with phpmyadmin, etc. Seems perfect!

Install went fairly well, although it insists on being in the System applications folder and didn't like being installed in my User applications folder.

Now, the other thing I needed was a way to handle the domain names. I develop for four different domains, and I wanted an elegant way of handing the domain names on the development server. Apache's vhost module is the best way to deal with that, but MAMP doesn't use it by default. But from some previous explorations, I found some good hints that I used to get MAMP working with it, using alen.mobi's hints.

First, I edited MAMP's httpd.conf (/Applications/MAMP/conf/apache/httpd.conf) and added this line:

Include /Applications/MAMP/conf/apache/httpd-vhosts.conf

Next, I created the new file referenced in that line:

NameVirtualHost *:8888

<VirtualHost *:8888>

   ServerAdmin webmaster@localhost

   ServerName default

   ServerAlias *

   VirtualDocumentRoot "/Volumes/Users/jeff/Sites/%-2+/web/"

   UseCanonicalName Off

   LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon

   ErrorLog "/Volumes/Users/jeff/Sites/logs/vhost-error_log"

   CustomLog "/Volumes/Users/jeff/Sites/logs/access_log" common

</VirtualHost>

Note that you should match the port numbers above to the ones you have MAMP using. I also moved my logs into the Sites directory, but that's up to you.

To get the domains working, you have a few options. The easiest is to edit /etc/hosts and add the subdomains to the 127.0.0.1 entry. Or, you can use alen's instructions to create a local DNS entry.

,

Comments

One Problem with DNS

OK, I did notice one problem using a local DNS service - the proxy at work stopped working. So, I think it is easier in this case to add a line to /etc/hosts and not mess with running a DNS server.

Powered by Drupal, an open source content management system