I know, yet another lame acronym, but hey--it's no more lame than LAMP or LAMBDA and at least my flat panel iMac actually looks like a lamp. ;-) MAMBO stands for "Mac + Apache + MySQL + BlueDragon + Other Stuff" (yes, that's a REEEAL stretch to get that last O in there, so if you have a better idea let me know!) and is a great way to serve CFML apps on the cheap if you have a spare Mac laying around. Read on for all the nitty-gritty details!
A few weeks ago I mentioned that I got rid of my dedicated server, moved my blog over to HostMySite, and moved some smaller sites that I was hosting over to my 15" flat panel G4 iMac, so here's the details on my MAMBO setup. I'm hosting this over my DSL connection and so far it's working extremely well.Since Mac OS X (I'm on Tiger now, 10.4.1 to be exact) already has Apache built in, the web server part of things is actually quite simple. Just go into your System Preferences, then to Sharing, then turn on Personal Web Sharing. Voila, Apache is running. What this gets you is only one site and one docroot, however, so obviously some tweaking is necessary to get multiple sites running. This involves two things: a DNS server and Apache virtual hosts. DNS Server I don't know about you, but I tend to like keeping things as simple as possible, so I really didn't want to get into hosting my own DNS server, and I wasn't even sure if my ISP would allow that, so I looked for a way to host my DNS information somewhere else. I'm using dnsexit.com for this because it's free, and it supports dynamic DNS (even though my IP address hasn't changed since I got my service over a year ago). Other free DNS services tend to only allow subdomains of the DNS service domain (e.g. mydomain.dyndns.org), but with dnsexit.com you can have full domains as well as hosts, aliases, and MX records for each domain. Cool stuff. So basically I just set up each of my domains in dnsexit.com and pointed them all to my DSL's public IP address. Virtual Hosts The second thing to do is edit the httpd.conf file on the Mac so it supports multiple virtual hosts. If you've ever worked with host headers in IIS this is the same concept, you just have to edit a text file and restart Apache to get this working. It's really quite simple and once you know what you're doing is actually a bit simpler than dealing with the wizards in IIS. The httpd.conf file is located in your /etc/httpd directory, and you'll have to use a terminal window to see it (it doesn't show up in the Finder). Just open up a term window, navigate to that directory, and open up httpd.conf using pico (or your favorite text editor). You'll likely have to use the sudo command because of the permissions on the file, so if you want to use pico your command will look like this:
sudo pico httpd.conf After you enter this you'll be prompted for your root password and then pico will open up the configuration file. What you're looking for in this file is the VirtualHost section, and there is where you tell Apache "if someone hits this server using this URL, send them here." Rather than go into details about this, I'll point you to the Apache VirtualHost Docs for more information. There's also some great articles on MacDevCenter about web serving on Mac OS X. Some are a bit dated but the general principles still apply, and you can find good information here about enabling PHP and all sorts of other good web server-related stuff. While you're in your httpd.conf file you might also want to set up the default documents so index.cfm will come up automatically. (Yes, if you're still with me, this is all heading up to being able to serve CFML from the Mac for free!) See this article for more details on setting up your default documents. Web Site File Placement Finally, you of course need to know where to put your web site documents. Since we're using virtual hosts and pointing Apache to the docroot for each site the files can more or less be placed anywhere, but for organizational purposes as well as keeping with the conventions of OS X, I just created a new directory for each site under /Library/WebServer/Documents. OK, so at this point we have our DNS information in dnsexit.com, our virtual hosts set up in Apache, and our web site files in place. But what about a database? What about FTP? And most importantly, what about ColdFusion? Don't worry--this stuff is all a snap as well. Database Server This is a no-brainer. MySQL is fast, free, extremely capable, and works great on OS X. Gone are the days when you had to compile the source code for MySQL on OS X; they now have a very slick installer that even puts a little startup program in the System Preferences panel. Download it, install it, love it. I tend to just use MySQL from the terminal, but if you want some help with your MySQL administration, phpMyAdmin is a very nice browser-based admin tool. There is also a ColdFusion version called CFMyAdmin but I'm not sure it will work on the Mac with BlueDragon (I haven't tried). There are also some nice Mac and Java database admin programs that will give you a GUI but you'd still be using straight SQL for the most part, so if you want to avoid SQL for stuff like creating tables, etc. phpMyAdmin might be the way to go. Check out SQL Grinder or Aqua Data Studio for the Mac/Java option, or for more information on enabling PHP on your Mac, see this MacDevCenter article. FTP Access Unless you want to maintain the sites of all your mooch friends that are using your MAMBO box instead of getting cheap hosting elsewhere, they'll need FTP access. FTP is easy to enable on the Mac, but the issue is that for every FTP user you have to set up an account on your Mac for them. This is kind of a pain, and in my mind just isn't a great idea. Luckily there's another way, and yes it's free. (Sensing a trend here?) There's a very nice FTP server manager called PureFTPd Manager that gives OS X users a nice GUI frontend for the PureFTPd server, which I'm assuming is what OS X uses under the hood since it's based on BSD ... all I know is I installed the PureFTPd Manager and didn't have to install the server separately, and it seems to interact with the FTP checkbox in the sharing area of the System Preferences. So the cool thing here is you can set up a single user and group (I just called mine virtualftp) and then use virtual users through PureFTPd Manager, which means you don't have to create an account on the Mac for each FTP user. Slick. Just make sure you set the permissions correctly on your /Library/WebServer/Documents directory so the virtualftp user has the access it needs and the rest takes care of itself more or less. I also gave one trusted soul ssh access because he likes to just log onto the server and edit directly using vi, so he's happy with the MAMBO setup as well. And saving the best for last ... CFML: Served by BlueDragon By now most CFers are aware of New Atlanta's alternative CFML engine BlueDragon, but if you aren't, you need to be. It's a great product, it's supported for production use on the Mac, and they have a version that's free to use in production environments. That's right--free! Perfect price tag for the MAMBO box. Basically all that's involved here is to go to New Atlanta's web site and download the free version of BlueDragon for Mac OS X and install it. It works great with the version of Apache that comes with OS X and configures itself automatically IF YOU READ AND FOLLOW THE INSTALLATION GUIDE. There are some symbolic links you have to set up to get it to work automatically and I strongly suggest you do this. If you set up the symbolic links and install BlueDragon while Apache is still running, then it will configure itself with Apache automatically. After an Apache restart you can serve up CF apps to your heart's content! I'm pretty sure BlueDragon even sets itself up to start automatically when the server restarts, but make sure you read the BlueDragon guides for any issues related to that. Mine works, I just don't remember if I had to do anything to get it to start automatically or not. So there you have it, MAMBO in a nutshell. O'Reilly, I'm available to write up a book on this if you're interested. ;-) I hope that helps some of you Mac folks out there (particularly the newbies) with getting a solid CF-serving environment set up on the Mac. And hey, with enough demand maybe Macromedia will make ColdFusion a first-class citizen on the Mac as well.