In the previous two parts we installed Tomcat. Now lets set up Apache httpd server.

I suggest downloading Apache from Apache Lounge. The nice thing about Apache Lounge's builds is that they include mod_rewrite and mod_ssl.

The latest version at the time of this writing is 2.2.14. Download httpd-2.2.14-win32-x86-ssl.zip and open it in your favorite archiver (mine is WinRar).

I recommend taking the Apache2 folder inside the zip file and placing it on c:\. After you've done this you should have a c:\Apache2 folder with many files and subfolders in it.

Open c:\Apache2\conf\httpd.conf file in your favorite text editor. I recommend Textpad.

I usually change a few things from the defaults. Your configuration may differ.

Change

view plain print about
1ServerAdmin admin@example.com
to your email address.

Uncomment the following modules:

view plain print about
1#LoadModule proxy_module modules/mod_proxy.so
2#LoadModule proxy_http_module modules/mod_proxy_http.so
3#LoadModule rewrite_module modules/mod_rewrite.so
by removing the # sign in front of the line.

Find the line that says

view plain print about
1<Directory "c:/Apache2/htdocs">

After closing directory tag lets add one allowing access to our web root. I usually set up a folder or a new drive for it. Lets say we set up a webroot of "c:\websites". Create a folder websites on c: and then inside it create another folder called railotest. We will use this to set up our test site.

After the closing tag, add a new one allowing access to our web root.

view plain print about
1<Directory "c:/websites">
2 Options Indexes FollowSymLinks
3 AllowOverride None
4 Order allow,deny
5 Allow from all
6</Directory>

This will allow Apache to serve from anywhere inside c:\websites. Alternatively, you can set up a new directory entry for every site that you create, but I find that this makes things easier without significantly impacting security.

Find the line that says

view plain print about
1DirectoryIndex index.html

and add index.cfm to that list

view plain print about
1DirectoryIndex index.html index.cfm

Uncomment the line that says

view plain print about
1#Include conf/extra/httpd-vhosts.conf
by removing the # sign.

Now open up httpd-vhosts.conf file that is located in "C:\Apache2\conf\extra".

There are two sample virtual hosts defined. Lets comment them both out. Alternatively you can just delete them.

view plain print about
1<VirtualHost *:80>
2 ServerAdmin webmaster@dummy-host.example.com
3 DocumentRoot "c:/Apache2/docs/dummy-host.example.com"
4 ServerName dummy-host.example.com
5 ServerAlias www.dummy-host.example.com
6 ErrorLog "logs/dummy-host.example.com-error.log"
7 CustomLog "logs/dummy-host.example.com-access.log" common
8</VirtualHost>
9
10<VirtualHost *:80>
11 ServerAdmin webmaster@dummy-host2.example.com
12 DocumentRoot "c:/Apache2/docs/dummy-host2.example.com"
13 ServerName dummy-host2.example.com
14 ErrorLog "logs/dummy-host2.example.com-error.log"
15 CustomLog "logs/dummy-host2.example.com-access.log" common
16</VirtualHost>
should look like this:

view plain print about
1#<VirtualHost *:80>
2# ServerAdmin webmaster@dummy-host.example.com
3# DocumentRoot "c:/Apache2/docs/dummy-host.example.com"
4# ServerName dummy-host.example.com
5# ServerAlias www.dummy-host.example.com
6# ErrorLog "logs/dummy-host.example.com-error.log"
7# CustomLog "logs/dummy-host.example.com-access.log" common
8#</VirtualHost>
9#
10#<VirtualHost *:80>
11# ServerAdmin webmaster@dummy-host2.example.com
12# DocumentRoot "c:/Apache2/docs/dummy-host2.example.com"
13# ServerName dummy-host2.example.com
14# ErrorLog "logs/dummy-host2.example.com-error.log"
15# CustomLog "logs/dummy-host2.example.com-access.log" common
16#</VirtualHost>

Now lets add a new entry for our test server

view plain print about
1<VirtualHost *:80>
2 DocumentRoot "C:/websites/railotest"
3 ServerName railotest
4 ErrorLog "logs/railotest.com-error.log"
5 CustomLog "logs/railotest-access.log" common
6</VirtualHost>

Now save the files and lets try running apache and see if it worked. Open up command prompt (Start -> Run -> cmd.exe)

view plain print about
1Microsoft Windows [Version 5.2.3790]
2(C) Copyright 1985-2003 Microsoft Corp.
3
4C:\Documents and Settings\Administrator>
cd \apache2\bin
5
6C:\Apache2\bin>httpd
7httpd: Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xxx.xxx for ServerName
We can ignore that warning since we don't care about the default configuration.

Now we will need to define a host called railotest using windows hosts file. Open up "C:\windows\system32\drivers\etc\hosts" file in your favorite text editor.

After a bunch of comments, you should see

view plain print about
1127.0.0.1 localhost

Lets add an entry for railotest

view plain print about
1127.0.0.1 railotest

Now this computer knows that railotest points to 127.0.0.1.

Lets put a test cfm file in the webroot for railotest. Create a new file called index.cfm and put it in c:\websites\railotest.

Inside the file lets put some basic cf code

view plain print about
1<cfdump var="#server#">

If you still have apache running and put in http://railotest in your browser you should see the code being output. It is not being interpreted yet because we have not hooked up Apache httpd to Railo. We will do this in Part IV.

For now lets set up apache to run as a service.

First stop the httpd that you ran earlier by entering ctrl-c and do the following.

view plain print about
1C:\Apache2\bin>httpd -k install
2Installing the Apache2.2 service
3The Apache2.2 service is successfully installed.
4Testing httpd.conf....
5Errors reported here must be corrected before the service can be started.
6httpd: Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xxx.xxx for ServerName

The Apache service is now installed. I recommend also adding the "Apache Monitor" app to your startup folder.

Click Start->All Programs and right click on Startup. Now click "Explore All Users". In another explorer window open up C:\Apache2\Bin and right drag ApacheMonitor.exe to the Startup folder. Let go of the right mouse button and select "Create shortcut here".

Double click on the shortcut and the monitor App should appear in your taskbar next to the clock and next to Tomcat's icon.

Double click it to open it and click start. Now you have a working Apache installation that will start as a service.

If you enter http://railotest in your browser, you should see the code we wrote earlier. This will persist across reboots.

In the next part, we'll hook it up to Railo and be able to actually execute this code.