I've just set up my local development environment on my Mac... something I've never done before.

I've done it many times on Ubuntu and Windows, and most of it's the same, but I thought I'd record the process, mainly for my own future reference.

Installing MAMP is easy, you just download the installer/zip thing from their site: http://www.mamp.info/en/index.html

After that, I installed Railo, which was a fairly similar process, it only took a few minutes using their installer: http://www.getrailo.org/index.cfm/download/

Then after that it gets a bit awkward. I'm building my sites using Coldfusion Builder, and they're hosted on github as well. So first thing you've got to do is make your local directory, it doesn't really matter where you put it but I used the default htdocs folder of the MAMP install: /Applications/MAMP/htdocs/SiteName

I used git to clone down my repo, and that made the folder structure for me:

view plain print about
1cd /Applications/MAMP/htdocs/
2git clone git@github.com:Willshaw/SiteName.git

In order to do that you've got to have you .ssh keys setup, but you don't need to use git, you just have to have your local website files somewhere on your hard drive.

Once you've got some site files to use you've got to do 3 things:

  • Tell the Railo install where they are
  • Create a VirtualHost element in your apache config files
  • Tell Mac OS X that you have a local site

To get railo working, you need to edit the /Library/Railo/tomcat/conf/server.xml file. At the bottom there will be some commented out code telling you how to add a new railo context. Basically you just have to give it the path to your site files, and the name of your local domain... you have to make this up now. It can be anything, like localDevSite, or fatPigsSmell, anything at all.

view plain print about
1<!--
2 Add additional VIRTUALHOSTS by copying the following example config:
3 REPLACE:
4 [ENTER DOMAIN NAME] with a domain, IE: www.mysite.com
5 [ENTER SYSTEM PATH] with your web site's base directory. IE: /home/user/public_html/ or C:\websites\www.mysite.com\ etc...
6 Don't forget to remove comments! ;)
7 -->

8 <!--
9 <Host name="[ENTER DOMAIN NAME]" appBase="webapps">
10 <Context path="" docBase="[ENTER SYSTEM PATH]" />
11 </Host>
12 -->

13
14    <Host name="localSite" appBase="webapps">
15        <Context path="" docBase="/Applications/MAMP/htdocs/SiteName" />
16    </Host>

You should see it down at the end of the server.xml file.

Once you've done that, you need to restart railo. You can do this by simply going to the administrator and clicking the restart link on the left hand side, under the services category in the menu.

When railo has restarted you should see a WEB-INF folder in your local site files that railo has created, and you'll also see your site files listed as a context at the bottom of the page when the administrator loads.

If you're not with me at this point... then sorry. Email me I might be able to help.

If you've got the WEB-INF file, then woohoo. Almost there.

Next you have to tell apache that you're running a whole new website on your server. So you edit /Applications/MAMP/conf/apache/httpd.conf and add lines similar to the following at the very end:

view plain print about
1<VirtualHost *>
2    DocumentRoot "/Applications/MAMP/htdocs/SiteName"
3    ServerName localSite
4</VIrtualHost>

You basically telling apache exactly the same things you told railo. I don't know why railo can't just copy apace, it's annoying.

The last thing to do is tell mac os x that when you type http://localSite you want to look at your local development website, you don't want to go hunting for it on the internet.

So you edit /etc/hosts and simply add the new local host name to the end of the list after 127.0.0.1, so it looks something like this

view plain print about
1##
2# Host Database
3#
4# localhost is used to configure the loopback interface
5# when the system is booting. Do not change this entry.
6##
7127.0.0.1    localhost localNPT

And that's all I did. Now when I visit http://localSite, I get a copy of my website, pulled down from github.

If this doesn't work for you, or it breaks anything, well sorry but web servers are a pain in the arse. Restart everything. That usually fixes it.

I have to give credit to these 2 blog posts that helped me out:

http://kisdigital.wordpress.com/2011/11/16/adding-new-sites-to-railo-demystified/
http://wordpress.org/support/topic/wordpress-3-network-multisite-on-a-local-development-site?replies=49

On that second one it was the replies from keesiemeijer that really helped