Vagrant, VitualBox, and Apache

In the Office I have been recently tasked with completion of the Vagrant local environments, and just this week I have managed to get it up and running. I wanted to give a quick run down of how I managed this for others to follow.

The Starting Box

I started with a pre-made virtualBox giving to me from the Sys Ops team with the following configuration.
- Windows Server 2008 R2 64bit - IIS 7.5 - ColdFusion 9.x.x

The Final Box

I ended with this configuration for the box.
- Windows Server 2008 R2 64bit - Apache 2.2.x - ColdFusion 9.x.x

I know this doesn't seem like a large difference, but there many little challenges I needed to work trough.

The Setup

Disable IIS

First step was to disable IIS so that we could free up Port 80 for Apache httpd. First thing I did was remove IIS from the web config tool. Once that was done, I disable the service that reserves port 80 for IIS.

  1. Open Services
  2. Edit: "World Wide Web Publishing Service"
    • Stop the Service / Process
    • Set "Startup Type" to "Manual" or "Disabled"

Before restarting the server, make sure "VirtualBox Guest Additions" are installed. This will allow windows to access vagrants sync'd folders.

Restart the VM

Setup and Install Apache Httpd

First problem encountered here is that Apache Httpd is a 32bit application by default, and my version of CF9 and JVM are 64bit. You can configure ColdFusion and JVM to play nicely with a 32bit Apache, but its a great deal easier to find a 64bit compile of Apache httpd. I found one on BlackDot here : https://blackdot.be/wp-content/plugins/download-monitor/download.php?id=httpd-2.2.19-win64.rar.

Simply unzip the download to your install location. I used "C:\Apache2.2" for convenience. Because I changed the location of httpd from set location, I needed to edit the config file (C:{apache install}\conf\httpd.conf).

ServerRoot "/Apache2.2"  
...
LoadModule rewrite_module modules/mod_rewrite.so # uncommented for URL Mod Rewrite  
...
DocumentRoot "/Apache2.2/htdocs"  
...
<Directory "/Apache2.2/htdocs">  
    ...
    AllowOverride All
    ...
</Directory>  
...

Once that is saved, I installed Apache as a Service on the system. Open command line, and navigate to "C:{apache install}\bin".

httpd.exe -k install  

This installed and starts Apache as a Service on windows. If Apache doesn't start up, then there is an issue with your config file. Double check it and try to start the service manually.

Setup ColdFusion for Apache

This part is actually rather easy. Open up your ColdFusion Web Config Tool and add apache as a server. I opted to: Configure web server for ColdFusion 9 application. This will add in a bunch of JRun stuff to the httpd.conf file we were in before.

Conclusion

Once ColdFusion is set, you should be able able to start using apache with coldfusion on the server. Shut it down and package up the box for Vagrant distribution.

Next up: Using the Box with Vagrant