Railo Installation and Setup (CentOS, cPanel and Resin)

Hi Guys,

I’ve been thinking and I want this blog to be a useful repository of my ramblings and experiences so that others can make use of them.

Primarily this post was originally going to be for my own use, but I think that the community at large will be able to benefit from it.

There will be an update to this at some point in time as the installation that I have here is far from perfect but it will give you a good starting block on how to get Railo  up and running quickly and efficiently.

Step 1: – Gather all the required elements to make this work.

  1. This blog post for instructions (Duh!)
  2. You will need Java JDK (Java development toolkit) ( will be referred to simply as JDK ) – The JRE Installation on its own is unfortunately not sufficient enough to be able to run railo. – The latest version available will be suitable to run Resin and Railo ( At the time of writing the latest version was 1.6.0 U19 ) Please Note: You will need to download your platform dependant version of jdk.
  3. You will need a copy of Caucho Resin ( http://www.caucho.com/download/resin-3.1.10.tar.gz ) – For this installation i selected Resin 3.1.10 ( latest )
  4. You will need a copy of Railo ( http://www.getrailo.org/down.cfm?item=/railo/remote/download/3.1.2.001/custom/all/railo-3.1.2.001-jars.tar.gz ) – The version that has been selected for this installation is Railo 3.1.2 ( latest )

The above components are listed as they are what i have used on my installation.

Step 2: The installation.

Once you have downloaded all the components as the root user I (for sake of easy management and updates in future) moved the JDK installation binary and also resin-3.1.10.tar.gz to the “/opt” directory, this will assist in future for any updates etc as everything is located in a single place.

Once the files was moved i initiated the JDK installation by running

root@ukws /opt $: ./jdk-6u19-linux-i586.bin

This started the installation of the JDK, What follows is a fairly lengthy legal document that Oracle would like you to read. After which once you have come to the end of the licence agreement it will ask you if you choose to accept the agreement or not. You will either have to answer [yes] or [no] at this point. For the installation to continue you have to answer [yes].

Once the licence agreement has been accepted for the JDK, the installer will begin extracting and verifying the content of the binary installer. Once completed you will have a directory like.

jdk1.6.0_19

To make matters easier and instead of typing jdk1.6.0_19 every time i needed to access the java directory i created a symlink to this directory using…

ln -s jdk1.6.0_19 java

Then to satisfy the operating system path veriable and to negate the use of specifying a seperate JAVA-HOME path I created the following symlink…

cd /usr/local

ln -s /opt/java jdk

I then returned to the /opt directory to continue.

Now the JDK has been installed its time to install Caucho Resin ( I chose this java application server as after much research I found other peoples experience with it to be better within a hosting environment.

To start the installation first we need to extract resin from its tarball, to do this i use the command.

tar zxfv resin3.1.10.tar.gz

This will extract all the files to a directory of the same name, in this case “resin3.1.10″

To simplify matters and to allow upgrading in the future (to help prevent breaking custom scripts). I create another symlink..

ln -s resin3.1.10 resin

Now its time to build the resin instance, I took the following steps.

cd resin

./configure --with-apache=/usr/local/apache; make; make install

This process will not take long to complete.

Once this has completed there are a few things to configure before you start to use resin.

At this point I would like to say that by using the –with-apache tag the Caucho Resin build has created the module and inserted the code into the apache httpd.conf file so apache will require a restart. To do this run the command…

service httpd restart

Now we are at the point where we need to configure Resin to run on your server, by default resin will take control of .jsp, .jspf, .jspx, .php. While this is a good starting point for many apache users as we are running a cPanel installation chances are that you have already used EasyApache installation script to setup your apache installation already and as such most probably have PHP already setup.

From what I can tell ( This is purely my oppinion and isnt intended as an insult to the creators of a great product), but. If its not broken why try to fix it? I have found that the Resin implimentation of PHP can cause some issues with existing sites that currently run on PHP, this may be due to the security limitations of running PHP code within a java virtual machine but it can cause a lot of upset customers. (including yourself).

To configure Resin (without Railo at the time being) I took the following steps…

cd /opt/resin/conf

( I choose nano as my text editor but feel free to use whatever you like )

nano app-defaults.xml

I then moved down to the line containing.

<servlet-mapping url-pattern="*.php" servlet-name="resin-php"/>

And removed it (as we dont want resin to compile our PHP pages as per my comment above)

I then moved down to the line containing.

<welcome-file>index.php</welcome-file>

And removed it.

This taken care of i saved the document (Ctrl + O In Pine) and exited (Ctrl + X)

I then opened the main Resin configuration file.

nano resin.conf

I moved down to the line…

<!-- define the servers in the cluster -->
<server id="" address="127.0.0.1" port="6800"/>

and changed it to..

<!-- define the servers in the cluster -->
<server id="dews" address="127.0.0.1" port="6800"/>

This will make starting the server instance easier when we come to it later. I then moved further down the document to…

<resin:set var="resin_admin_external" value="false"/>

And changed it to…

<resin:set var="resin_admin_external" value="true"/>

This will enable public access to the resin configuration.

Now we need to save these changes and edit your editor (Ctrl + O) (Ctrl + X)

Now we need to run the Resin Instance which we will do by doing the following.

cd /opt/resin/bin

./httpd.sh -server dews start

This will return “Resin/3.1.10 started -server ‘dews’ for watchdog at 127.0.0.1:6600″ and return you back to the command line.

Now we have Resin up and running you need to define a username and password for the Resin administrator. To do this open your web browser of choice and navigate to http://<your servers base hostname or ip>:8080/resin-admin/

This will bring up a page with a login box and a username/password hash creation tool, We will need the bottom tool for the next part, please enter your username, password, and password again and click on submit. the following page will contain a small information box which will have a very small code block which within it will have a line similar to:

<user name="administrator" password="s6er3tDlJ5S+WAMK1qvnCQ=="/>

This needs to be coppied to your clipboard and we need to go back into your ssh connection.

re-open the resin.conf file and navigate down to the line which say…

<management path="${resin.root}/admin">
<user name="admin" password="password" disable="true"/>

Paste the line which the web interface gave you under the <user name=”admin… line and save (Ctrl + O). As resin continually monitors all of the configuration files in relation to resin by default for any changes, once you have saved the username, within a couple of seconds you will be able to login with the username and password you gave to the hash tool.

Now we need to add a virtual host as so we can test the installation of Resin on your cPanel installation.

Still within the resin.conf move down the config file so untill you come to:

<prologue>
<resin:set var="resin_admin_external" value="true"/>
<resin:set var="resin_admin_insecure" value="true"/>
</prologue>
</web-app>
</host>
</cluster>

Now, between the two closing tags “</host></cluster>” we are going to enter the virtual host entry into here, the code block which we will use is:

<host id="<domain>" host-name="www.<domain>" root-directory="/home/<username>/" >
<web-app id="/" root-directory="public_html" />
</host>

I have chosen this method as it allows me to define Railo to specific virtual hosts (instead of everyone). <domain> is your domain name without the www. prefix and <username> is the username that is used by cPanel to generate your home directory.

Now we once again need to save the resin.conf file and give the resin server time to restart itself.

In your favorite html editor we are going to create a sample.jsp test page.

I used the code:

<HTML>

<HEAD>
<TITLE>hello jsp</TITLE>
<!-- the variable, message, is declared and initialized -->
<%!
String message = "Hello, World, from JSP";
%>
</HEAD>

<BODY>

<!-- the value of the variable, message, is inserted between h2 tags -->
<h2><font color="#AA0000"><%= message%></font></h2>

<h3><font color="#AA0000">
<!-- the java.util.Date method is executed and the result inserted between h3 tags -->
<%= new java.util.Date() %>
</font></h3>

</BODY>

</HTML>

In the sample.jsp file i created and uploaded it to my domain that i added the virtual host for, then in a web browser navigate to that domain name and try and access the sample.jsp file which you have just uploaded.

If all is well you will get a display similar to:

Hello, World, from JSP

Thu Apr 01 23:27:07 PDT 2010

If you get this then Congratulations! you have successfuly installed Resin Application Server.

OK!, so now you have resin installed we just need to complete the Railo Installation and intergration with Resin.

We now need to exit the resin.conf file and navigate back to /opt, once back at this point we need to extract the Railo files so we can add them to Resin, to do this i took the following action.

tar zxfv railo-3.1.2.001-jars.tar.gz

Then i moved the contents of railo-3.1.2.001-jars using…

mv railo-3.1.2.001-jars/* /opt/resin/ext-webapp-lib/

Now we need to finalise the configuration of Resin to enable Railo and coldfusion functionality, to do this you need to edit the app-default.xml file again.

cd /opt/resin/conf

nano app-default.xml

Navigate down to the last </servlet> tag and then paste the following code:

<servlet servlet-name="CFMLServlet" servlet-class="railo.loader.servlet.CFMLServlet">
<init-param>
<param-name>railo-web-directory</param-name>
<param-value>{web-root-directory}/WEB-INF/railo/</param-value>
<description>Railo Web Directory directory</description>
</init-param>
<!-- init-param>
<param-name>railo-server-directory</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="AMFServlet" servlet-class="railo.loader.servlet.AMFServlet">
<load-on-startup>2</load-on-startup>
</servlet>

Now we need to add in the servlet mappings, after the last <servlet-mapping entry please add the following block of code:

<servlet-mapping url-pattern="*.cfm" servlet-name="CFMLServlet"/>
<servlet-mapping url-pattern="*.cfml" servlet-name="CFMLServlet"/>
<servlet-mapping url-pattern="*.cfc" servlet-name="CFMLServlet"/>
<servlet-mapping url-pattern="*.cfm/*" servlet-name="CFMLServlet"/>
<servlet-mapping url-pattern="*.cfml/*" servlet-name="CFMLServlet"/>
<servlet-mapping url-pattern="*.cfc/*" servlet-name="CFMLServlet"/>
<servlet-mapping url-pattern="/flashservices/gateway/*" servlet-name="AMFServlet"/>

Ok, we are almost there, now please scroll down to the

<welcome-file-list>

xml block which contains multiple instances of <welcome-file> tags, within this block please add <welcome-file>index.cfm</welcome-file>. Now we need to save the app-default.xml file and give Resin a chance to restart. you should now be able to access the Railo Administration pages by visiting: http://<hostname you entered into resin.conf as virtual host>/railo-context/admin/server.cfm

With this setup each individual virtual host has its own server entry and its own context, i will be updating this post at some point (maybe with a part 2) which will give details on how to convert this to run with a single server.cfm instance to control all web instances on the server.

As with anything opensource, this guide is free (as in beer) but if it feels like it has a dire need to burn your house down, format your servers,  or drop kick your computer monitor, then harrassed.net accepts no responsibility for the above actions or any failure on your part to ahear to good computer practices.

Tags: , , , , , , , ,

3 Responses to "Railo Installation and Setup (CentOS, cPanel and Resin)"

Leave a Comment

You must be logged in to post a comment.