Web development on a Mac is pure joy. There are so many tools that just that make building websites simple and even fun. From the dead-simple MAMP web server setup to the deceptively powerful TextMate editor to the game-changing Firefox browser-cum-editor/tester (with the essential Web Developer, FireBug, and ySlow extensions), it’s all good in Mac land.
And since Mac went Intel, we can develop like crazed bunnies and test our work in each nasty little flavor of Internet Explorer running in separate virtual Windows environments. Granted, it took a bit of Googling on my part to find out how to point Windows browsers to MAMP. But the two primary solutions are fairly straight forward and work in most cases:
- use the Mac’s IP address (e.g., 192.168.2.2:8888)
- create and use a hostname
- open the
C:\WINDOWS\system32\drivers\etc\hostsfile (in Notepad)
- add a line to the bottom with the Mac’s IP address and desired hostname (e.g.,
192.168.2.2 mamp) and save
- use that hostname (e.g., http://mamp:8888)
- open the
In most cases? Yep. Everything runs fine so long as your apps don’t reference MAMP’s default webserver name,
localhost:8888. Of course, the popular apps such as ExpressionEngine and WordPress do need a base URI—and
localhost:8888 is it.
Bugger. Windows has it’s own
localhost quite separate from Mac’s and neither the two shall meet. Accessing MAMP’s
localhost just isn’t going to happen with Windows’
localhost listening in and intercepting. The only solution is to set up a hostname other than
localhost on the Mac side and enter that same name in the Windows
host config file.
The gritty, command-line way of changing MAMP’s hostname from
localhost is to make some changes to its
httpd.conf file and to muck with
dscl (Apple’s NetInfo replacement). Feel free to Google the specifics, but I personally don’t want to have to fire up Terminal every time I want to change to another site. Thank goodness for VirtualHostX.
My new pal, VirtualHostX, allows me to create different virtual host names for all my projects. So rather than using the
localhost URI, I can create meaningful URI’s such as
anotherproject.dev with impunity (which makes it superior to the Headdress method of merely assigning new port numbers to
localhost). VirtualHostX makes all the changes behind the scenes and even backs up the default settings before making those changes. Sweet!
We’ve almost achieved web developer inner-peace… but we need to make one more stop. Let’s remove that crufty port 8888 bizness (e.g.,
myproject.dev:8888). By default, MAMP uses port 8888 to avoid conflicts with OS X’s built-in web server (which listens to the http default port 80). Since I have no immediate intentions of using OS X’s built-in server, I immediately changed MAMP’s default port setting to good ole port 80. From here on out, just enter
myproject.dev in any Mac browser and go. Yay. Nirvana.
Now, back to the Windows side. After adding
myproject.dev to the Windows
host file (e.g.,
192.168.2.2 myproject.dev), fire up your Windows browser of choice, point it to
myproject.dev, and Shazam! Everything works.