After a bit of fiddling and head scratching I managed to install Railo on Tomcat via Apache on my laptop running on OS X 10.5.6.
Tomcat
Firstly, download
Tomcat 6
extract content:
tar xvzf apache-tomcat-6.0.18.tar.gz
Move Tomcat to a more secure place:
sudo mv apache-tomcat-6.0.18 /usr/local/tomcat
Railo
Download
Railo custom version
extract and move into Tomcat lib directory:
tar zxvf railo-3.0.2.001-jars.tar.gz
sudo mv railo-3.0.2.001-jars/* /usr/local/tomcat/lib
Make Tomcat and Railo work together by modifying the web config file:
sudo nano /usr/local/tomcat/conf/web.xml
add the following inside the <web-app> element:
<servlet>
<servlet-name>CFMLServlet</servlet-name>
<servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>
<init-param>
<param-name>configuration</param-name>
<param-value>{web-root-directory}/WEB-INF/railo/</param-value>
<description>Configuraton directory</description>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfc</url-pattern>
</servlet-mapping>
add the following inside <welcome-file-list> element:
<welcome-file>index.cfm</welcome-file>
<welcome-file>index.cfml</welcome-file>
Apache
Leopard OS comes with Apache 2, so you don't have to worry about installing it. However, you need to download
The Apache Tomcat Connector source code.
Next you need to compile the source so that the resulting binary file is compatible with your Intel Mac architecture. I got this from Eric Rank's blog
cd into tomcat source:
cd tomcat-connectors-1.2.27-src/native
Edit the apache-2.0/Makefile.apxs.in file.
Replace
mod_jk.la:
$(APXS) -c -o $@ -Wc,"${APXSCFLAGS} ${JK_INCL}" "${JAVA_INCL}" "${APXSLDFLAGS}" mod_jk.c ${APACHE_OBJECTS}
with:
mod_jk.la:
$(APXS) -c -o $@ -Wc,"${APXSCFLAGS} -arch x86_64 ${JK_INCL}" "${JAVA_INCL}" "${APXSLDFLAGS} -arch x86_64 " mod_jk.c ${APACHE_OBJECTS}
configure the build files:
./configure --with-apxs=/usr/sbin/apxs
now go into apache-2.0 directory and build:
cd apache-2.0
make -f Makefile.apxs
Finally install
sudo make install
Now specify the connection between Apache and Tomcat. To do this you need to create workers.properties file. I created mine in /etc/apache2.
sudo nano /etc/apache2/workers.properties
Paste the following:
worker.list=default
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
Now we need to modify the Apache httpd.conf file:
sudo nano /etc/apache2/httpd.conf
Enable The Apache Tomcat Connector:
LoadModule jk_module libexec/apache2/mod_jk.so
Underneath that tell Apache where your workers.properties file is located and add some logging info (could be useful):
# Mod_jk settings
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel debug
DirectoryIndex index.html index.htm index.cfm index.cfml
Back to Tomcat
To test our Railo installation, let's create a test site by adding a new virtual host in both Tomcat and Apache. We do this by modifying Tomcat server.xml file (/usr/local/tomcat/conf/server.xml )
<Host name="railo.local" appBase="webapps">
<Context path="" docBase="/Library/Webserver/Documents"/>
</Host>
Apache
Now we need to create a virtual host entry in Apache as well:
<VirtualHost *:80>
JkMount /*.cfm default
ServerName railo.local
DirectoryIndex index.cfm
</VirtualHost>
JkMount /*.cfm default
Tells mod_jk to use the connector specified in your workers.properties file when it encounters a .cfm extension.
Important
Notice that in my Apache VirtualHost entry there is no DocumentRoot. I originally had it in there and it was breaking my Apache-Tomcat connection. It was driving me mad. It's probably because document root is already specified in /usr/local/tomcat/conf/server.xml.
One last thing, to start your Tomcat server type in this command:
/usr/local/tomcat/bin/startup.sh
shut down
/usr/local/tomcat/bin/shutdown.sh
My assumption is that the above steps would be very similar on other operating systems as long as you use the correct file paths.
Good luck :-)
Marko
8 Comments
You apache vh documentroot probably doesn't work because your tomcat host file isn't right.
We did almost the same install and I finally blogged it the other day, you might want to look at this step http://www.deliciouscoding.com/post.cfm?entry=5-ra... and look at the tomcat host file, specifically your appbase and docbase.
appBase is your tomcats webapps where railo is running
docBase is where you are keeping the sites files.
Yours "might" work but not sure if you have more than 1 site
Also if you want remoting you need to add the amf tages in tomcats web.xml
Thanks for your input Dave. Good point about amf tags.
I figured out what my problem was. I also had JRun/Apache connector in my httpd.conf which was conflicting with my railo installation. I commented out "LoadModule jrun_module" line and that fixed it. There should be a way to run both JRun and Railo though, by conditionally loading the JRun module depending on the site you are trying to access. Yes, I do have more than one site.
I tried clicking on your link, but I got a 404.
Hi. Thank you very much for this extremely useful informtion. I followed it and was able to get almost everything working. Here are a few comments and questions:
1. Under "Back to Tomcat" you use appBase="/Users/marko/Sites/railo/www". I didn't notice this at first and copied/pasted it into my server.xml. Others following this example should replace with their own desired web root. I used /Library/Webserver/Documents.
2. Once I'd set everything up, if I went to http://127.0.0.1 I got the Tomcat index page. If I went to http://127.0.0.1/index.html I got /Library/Webserver/Documents/index.html which was what I wanted. I resolved this by using the following in server.xml instead of what was already there:
<Host name="localhost" appBase="/Library/Webserver/Documents" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="" />
</Host>
This was through trial and error so it may be wrong but it seems to work.
3. I'll keep looking for the answer to this one, but do you know how to set up SSL access for .cfm files? Right now, if I go to http://www.example.com/test.cfm it works, but if I go to https://www.example.com/test.cfm I just get returned the ColdFusion source. Anything else I've tried has either done nothing or has broken SSL access. If anyone could point out the solution to this, I'd very much appreciate it.
Thanks again,
- Andrew.
appBase is ALWAYS ALWAYS ALWAYS
appBase="webapps"
docBase for your example should be
docBase="/Library/Webserver/Documents/"
Thanks Dave. I'm still trying to figure all this out.
sure
you can always join the railo google group
this may help or not, I told someone I could install railo in under 5 min and they didn't believe me so I did it (in 3 min)
http://www.deliciouscoding.com/stuff/railo.mp4
Thank you - Thank you - THANK YOU :)
I have tried to get a good railo - apache setup going on OS X a few times but have failed. With this post I was finally able to do so - and Dave your comments were also very helpful.