Downloading
Start with a clean install of Tomcat. I downloaded 6.0.18 and unzipped it into /Developer/tomcat/. Don't start it up yet.
For Railo, you'll either need the custom JARs ZIP file or the WAR (which is just a ZIP anyway). The latter makes it a little easier to copy'n'paste the XML fragments you need to add to Tomcat's root web.xml file but I'll show them all below for convenience.
Preparation
In the Tomcat folder create a railo/ folder and copy in the contents of the unzipped Railo JARs ZIP file (or from the WEB-INF/lib/ folder of the unzipped Railo WAR file).
In the Tomcat conf/ folder, edit catalina.properties and find the common.loader class path. We're going to add the Railo JARs to the common class path so that every web application can have Railo CFML pages. The new common.loader definition should look like this (all on one line, no spaces):
${catalina.home}/railo,${catalina.home}/railo/*.jar
Unless you're going to use the default web applications that come with Tomcat, this is a good time to empty the Tomcat webapps/ folder. You could create a default/ folder in the Tomcat folder and move everything from webapps/ to default/ - this makes it easy to configure the applications again under a new hostname (I'll show this at the end).
Next we must configure the Railo Servlet stuff. In the Tomcat conf/ folder, edit web.xml. This is the master web application configuration for the Tomcat server and any web applications you create will inherit from it.
At the end of the servlet section, just before the servlet-mapping section, add the following:
<servlet-name>RailoCFMLServlet</servlet-name>
<description>CFML runtime Engine</description>
<servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>
<init-param>
<param-name>configuration</param-name>
<param-value>/WEB-INF/railo</param-value>
<description>Configuration directory</description>
</init-param>
<!-- init-param>
<param-name>railo-server-root</param-name>
<param-value>.</param-value>
<description>directory where railo root directory is stored</description>
</init-param -->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>RailoAMFServlet</servlet-name>
<description>AMF Servlet for flash remoting</description>
<servlet-class>railo.loader.servlet.AMFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>RailoFileServlet</servlet-name>
<description>File Servlet for simple files</description>
<servlet-class>railo.loader.servlet.FileServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
Next, at the end of the servlet-mapping section, just before the filter section, add the following:
<servlet-name>RailoCFMLServlet</servlet-name>
<url-pattern>*.cfm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RailoCFMLServlet</servlet-name>
<url-pattern>*.cfml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RailoCFMLServlet</servlet-name>
<url-pattern>*.cfc</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RailoAMFServlet</servlet-name>
<url-pattern>/flashservices/gateway/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<!-- could be RailoFileServlet -->
<servlet-name>default</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Finally, at end of the file, add index.cfm (and index.cfml if you wish) to the list of "welcome files".
If you emptied the webapps/ directory above, create an empty folder called ROOT/ in there so that we'll have at least one web application when we start Tomcat.
Let's get this party started!
We're ready to start Tomcat now. In Terminal, go to the Tomcat bin/ folder and start Tomcat:
At this point, the Server Administrator data is actually stored in {tomcat}/railo/railo-server/ and the Web Administrator data is stored in {tomcat}/webapps/ROOT/WEB-INF/railo/.
Settings in the Server Administrator cascade down into all the Web Administrators associated with the Tomcat server - and the Server Administrator can determine what features can be changed in those Web Administrators.
You can stop Tomcat now (by switching to the org.apache.catalina.startup.Bootstrap application and selecting Quit from the menu). The shutdown.sh script does not reliably shut Tomcat down for a number of web applications.
Adding websites
The first step is always to add a new domain name for each site to your local hosts file so all those domains resolve to 127.0.0.1.
Let's assume you have web1.local and web2.local defined there. Let's also assume that the desired webroots for these sites are ~/Documents/sites/web1.local/www/ and ~/Documents/sites/web2.local/www/.
In the Tomcat conf/ folder, edit server.xml and find the Host definition for localhost (around line 126). You can add your new host definitions below that, as follows:
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/Users/yourname/Documents/sites/web1.local/www"/>
</Host>
<Host name="web2.local" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/Users/yourname/Documents/sites/web2.local/www"/>
</Host>
Browse to http://web1.local/railo-context/admin/web.cfm, set a new password and login. This is the Web Administrator for the web1.local website. Similarly, http://web2.local/railo-context/admin/web.cfm is the Web Administrator for the web2.local website.
The Server Administrator accessible from http://web1.local/railo-context/admin/server.cfm is the same, shared Server Administrator under localhost or web2.local.
You now have a shared hosting environment on your local computer with each 'account' having its own full administrator console!
Those default Tomcat applications
Remember we moved those default applications (docs, examples, host-manager, manager, ROOT)? You can easily make them accessible again as a new website. Add tomcat.examples to your hosts file (resolving to 127.0.0.1) and then add the following to Tomcat's server.xml file:
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
When you next restart Tomcat, you'll see Railo's files added to the WEB-INF/ in each of those five web applications but you'll be able to browse to http://tomcat.examples/docs for example (and view the Tomcat documentation).
My entry on server.xml are <Host name="web1.local" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="c:\inetpub\wwwroot\web1.local"/> </Host> <Host name="web2.local" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="" docBase="c:\inetpub\wwwroot\web2.local"/> </Host>
I can see WEB-INF folder with subfolders like flex, railo and an .htaccess file under these two website folder. But once I access the website http://web1.local:8080/railo-context/admin/server.cfm Iam getting error says below
HTTP Status 404 -
type Status report
message
description The requested resource () is not available. Apache Tomcat/6.0.18
. Please note that IIS is running with CF8 on port 80 and thats the reason I called the railo webs using 8080 ports.
Please advice.
It's basically just as you've outlined things above, but I have the file system locked down a bit better and auto-run the Tomcat service as an unprivileged user. The is much more secure, but you need to be careful about providing the tomcat user permissions in any directories where Railo needs to write to the file system (e.g., WEB-INF under each Web root, by default). For development environments, it's of course easiest to keep things in a home folder, running as your main/regular user so there are no permissions to worry about.
I've also implemented your tips for AJP proxying from Apache and hiding/protecting the Railo Admin URLs.
@Jamie, yes, good points re: security - thanx for the link to your doc!
@Tom, yes, or a wildcard mod_proxy if you don't need per-virtual host specific Apache configuration (i.e., and let Tomcat handle everything).
@Shimju, a couple of questions: can you hit localhost:8080/railo-context/admin.cfm ? can you put a test.cfm file in web1.local and hit web1.local:8080/test.cfm ? That will show whether it's a problem with your basic Tomcat / Railo setup or just the Host/Context.
Remember, your best bet for support is either:
a) a paid support program from Railo -www.getrailo.com/index.cfm/services/support/
b) free support from the community - www.getrailo.org/index.cfm/community/mailing-list/
Now after system restart, everything seems working perfectly. Both web1.local:8080/ and web2.local:8080/ are working fine including railo context. I can able to hit localhost:8080/railo-context/admin.cfm earlier also. Thanks a lot Sean for this nice article. More I play on Railo, more it seems interesting. I bet Railo can bring more opensource applications into our CFML world.
<servlet> <servlet-name>RailoAMFServlet</servlet-name> <description>AMF servlet for flash remoting</description> <servlet-class>railo.loader.servlet.AMFServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <!-- MessageBroker Servlet --> <servlet> <servlet-name>RailoMessageBrokerServlet</servlet-name> <display-name>RailoMessageBrokerServlet</display-name> <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class> <init-param> <param-name>services.configuration.file</param-name> <param-value>/WEB-INF/flex/services-config.xml</param-value> </init-param> </servlet>
and <servlet-mapping> <servlet-name>RailoAMFServlet</servlet-name> <url-pattern>/openamf/gateway/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>RailoMessageBrokerServlet</servlet-name> <url-pattern>/flex2gateway/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>RailoMessageBrokerServlet</servlet-name> <url-pattern>/flashservices/gateway/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>RailoMessageBrokerServlet</servlet-name> <url-pattern>/messagebroker/*</url-pattern> </servlet-mapping>
Followed your blog and flawlessly deployed two railo apps side-by-side.
One additional note:
I added the MessageBrokerServlet definitions per: http://groups.google.com/group/railo/browse_thread/thread/1681fc25f23b3de3/d60b66a7ee9e7af7?lnk=gst&q=blazeds#d60b66a7ee9e7af7
Only I followed your lead and prefixed them as RailoMessageBrokerServlet and both apps now server data to flex via blazeds.
Thanks Again.
Full details are in https://jira.jboss.org/jira/browse/RAILO-400 including the per-webroot web.xml
The declaration is basically the same only for each with only a simple servlet and servlet-mapping declared in each web.xml
I think only the ServletId needs to be unique, but it doesn't hurt to namespace all of them.
Sorry for the introduction but i felt it necessary if i'm to figure out my issue as follows:
I followed the above perfectly and all seems to finally work. However, i have copies of web-inf in the following directories: home/resources/tc_#/conf/ home/resources/tc_#/webapps/ and where they should be: mydir/webroot/
My Catalina.Props file contains: common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,/home/resources/tc_3/railo,/home/resources/tc_3/railo/*.jar
My Server.xml Vhost: <Host name="sbiwd5.kattare.com" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" appBase="webapps"> <Context path="" docBase="/home/sites/spectrafluidics2_com" /> <Alias>www.sbiwd5.kattare.com</Alias> </Host>
Again, thanks so much for a great tutorial! Have any suggestions for this problem? I'm also going to try Jamie Krug's SES for Railo, Tomcat, and Mura CMS. Any suggestions on that one?
Thanks, David
I'm not sure if i should change this to UTF-8, but i looked at web.xml and that's what it had, so i wanted to keep them consistent. Is there a difference and should it be UTF-8? That would be good to know.
Thanks,
Hatem
http://corfield.org/blog/index.cfm/do/blog.entry/entry/Railo_for_Dummies_Part_III
you need to chmod to make the shell scripts executable:
chmod +x *.sh
Thanks for a great tutorial.
I had to include the oracle jar but didn't discover this until after following your instructions.
When I put this into {catalina.home}/railo it doesn't seem to be accessible by my subsites.
Is there any way to "refresh" all the jars those ones have access to?
Best regards, Andrew.
javax.servlet.ServletException: static path [/WEB-INF/railo/] for servlet init param [railo-web-directory] is not allowed, path must use a web-context specific placeholder.
Using the context variable like Resin app-default.xml uses Seems to fix the warning:
<param-value>{web-root-directory}/WEB-INF/railo</param-value>
However, each individial request is faster in Railo than CF-8.
The application being tested is a webservice and is exactly the same.
I would like someone to ponder over this with me :)
http://www.getrailo.org/index.cfm/community/


