Installing Resin/Railo on CentOS

There are a lot of users who would like to test Railo on their Linux systems but who are confused about how to get started. In this short tutorial I'm going to show you how easy it is to get up and running with a simple app server on CentOS 5.2. More tutorials are going to follow over the next weeks.

Introduction

I set up a server for hostek.com which is offering Railo VPS hosting in the future as well. There might be some paths related to the system at hostek, but they are of course only arbitrary. Since some hosters have already agreed on offering Railo hosting, we will publicize a list of them shortly on our website. So let's continue with the installation of Railo/Resin on CentOS 5.2.

Preparing the System

For this tutorial we assume that you have an installed Linux system running CentOS 5.2 with the latest updates applied. There should be a basic installation of the Apache Web Server present (if it isn't don't worry, it will get installed automatically by some of the commands we're going to issue later on). In addition you will need the base development tools like automake, autoconf, binutils and gcc. Those can be found in the section "Development", just use the standard settings there, no fancy stuff for X development needed. Also, you will need a working SSH connection to your server as the superuser "root".

To prepare the system for the configuration of Railo, some additional development libraries are needed. They are necessary because we need to compile an additional module (mod_caucho.so) for the Apache Web Server which essentially is the link between Apache and the Railo application server. Using CentOS, this is done with just one simple command on the shell (make sure you're logged in as the superuser "root"):
yum install httpd-devel openssl-devel lynx

The installation of the above packages takes only a couple of seconds. If you receive an error chances are that the yum service is not available. Please have your sysadmin install it for you in order to proceed.

Download and installation of Railo and the JRE

After installation of the development packages you have to download the required Railo/Resin package from the Railo website.
The link is: http://www.railo-technologies.com/down.cfm?item=/railo/remote/download/3.0.1.000/server/all/railo-3.0.1.000-resin-3.1.2-without-jre.tar.gz

Since it is best practice to keep your directories clean, so we are going to create some additional directories to store the downloaded files first:

cd ~
mkdir -p soft/tmp
cd soft/tmp
wget http://www.railo-technologies.com/down.cfm?item=/railo/remote/download/3.0.1.000/server/all/railo-3.0.1.000-resin-3.1.2-without-jre.tar.gz

As you may have noticed in the link name, the version downloaded comes without a JRE installed. You should therefore download a current JDK from Sun. Of course it might be a different one depending on the JDK version you are installing.

The link is: http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u12-linux-i586.bin?BundledLineItemUUID=KiZIBe.oZgAAAAEfbhMDp1qh&OrderID=VuNIBe.o9KoAAAEfYxMDp1qh&ProductID=1O1IBe.pLl4AAAEerDlTv_an&FileName=/jdk-6u12-linux-i586.bin
Please note that the download might have been removed by SUN due to a later version. So please check the link first, else wise the download below won't work.
IMPORTANT: When selecting the download, make sure to grab the JDK, not just the JRE! While the JDK contains everything needed to develop and therefore compile Java code and extensions, the JRE will only contain the code necessary to actually run Java apps. Since we are going to compile some stuff, the JRE won't suffice.
wget -o jdk-6u10-linux-i586.bin "http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u12-linux-i586.bin?BundledLineItemUUID=KiZIBe.oZgAAAAEfbhMDp1qh&OrderID=VuNIBe.o9KoAAAEfYxMDp1qh&ProductID=1O1IBe.pLl4AAAEerDlTv_an&FileName=/jdk-6u12-linux-i586.bin"

To be able to use the file just downloaded, we have to make it executable. Also, again to keep the system clean and the paths consistent, we create another directory where we are going to install all our stuff:

chmod 755 jdk-6u10-linux-i586.bin
cd /opt
mkdir soft
cd soft
/root/soft/tmp/jdk-6u10-linux-i586.bin
ln -s jdk1.6.0_10 java

This installs the JRE 6.0 updater 10 together with the JDK. The JDK contains the JNI libraries that speed up the performance of Resin. To be able to easily switch to a newer version of the JDK once that becomes available, we created a symlink named "java" in the last step. This gives us the additional benefit of being able to use a shorter name that's also easier to remember later on. Finally, we unpack the contents of the Railo package into the newly created folder /opt/soft and create a symbolic link to it as well.

#while still in /opt/soft
tar xzf /root/soft/tmp/railo-3.0.1.000-resin-3.1.2-without-jre.tar.gz
# shortcut to railo
ln -s railo-3.0.1.000-resin-3.1.2-without-jre railo

Compiling the connector module

First we have to configure the compilation. We have to point to the JDK home directory and to the path of the "apxs" utility that has been installed with the httpd-devel package at the beginning. So in order to configure the compilation we call:

# Change into the Railo directory
cd railo
# configure the compile process
./configure --with-java-home=/opt/soft/java --with-apxs=/usr/sbin/apxs

The important thing to look after is a line called:
"checking for JNI in /opt/soft/java/include/linux ... found"
in the output of the configuration utility execution. After the configuration we can build the module and install it:

# build the module
make
# install the module
make install

This step creates and installs the JNI libraries for Resin for a better performance of the application server. Also, the mod_caucho module for Apache is created and installed in the correct path. Lastly, some configuration changes are made to the httpd.conf of the Apache Web Server. To see what has happened in Apache you can edit the corresponding configuration file located here: /etc/httpd/conf/httpd.conf At the end of the file you can see the following:

LoadModule caucho_module /usr/lib/httpd/modules/mod_caucho.so
ResinConfigServer localhost 6800
CauchoConfigCacheDirectory /tmp
CauchoStatus yes

There you can see that the Resin connector has been loaded and that it listens on port 6800. In addition some other configuration parameters have been inserted.

In order to start the application server you need to call the following script. /opt/soft/railo/bin/httpd.sh start

But since it refers to a JRE that is only globally available on the system (without a path) we need to change the java setting to the correct path. It should be changed from "java=java" to "java=/opt/soft/java/bin/java". Then we can start the service.

/opt/soft/railo/bin/httpd.sh start

In order to check whether everything is all right with Resin and Railo just check the log files located under /opt/soft/railo/log. There you should see any occurring errors. Apache is configured and the module should be loaded. In order to check the Apache status just do the following:

<!-- change into the apache directory -->
cd /etc/httpd
apachectl -t
<!-- this should display something like: Syntax OK -->
<!-- then we can restart apache -->
/etc/init.d/httpd restart

Testing the functionality

Now everything is up and running. In order to test Railo and Resin you can place a file called caucho.conf into the conf.d directory containing the following entries:

<Location /caucho-status>
SetHandler caucho-status
</Location>

Now call the url: http://ipaddress/caucho-status. This should display the current status of Resin in your browser. In order to call Railo, just call the Railo administrator located here:
http://ipaddress/railo-context/admin.cfm
Then inside the server administrator you should set a server admin password and define a default password for all new web contexts. In order to configure Resin for multiple hosts, you can edit the resin.conf file and add host entries like for instance follows:

<host id="railo.hostek.com" root-directory="/opt/htdocs/wwwroot">
<web-app id="/" root-directory="railo.hostek.com" />
</host>

or if you want to create web contexts on a regexp basis on the fly, you can use the following:

<host regexp="(.+)">
<host-name>${host.regexp[1]}</host-name>
<root-directory>/opt/htdocs/wwwroot/${host.regexp[1]}</root-directory>
<web-app id="/" document-directory="."/>
</host>

This will implicitly create new web contexts inside the folder /opt/htdocs/wwwroot depending on the host name.

If you want to startup the httpd.sh at boot time as well, you need to copy the contrib/init.resin file to /etc/init.d/resin. Then you should do the following:

chkconfig --add resin
chkconfig resin on

I hope this works for all of you. If you have any comments or questions, let me know.

A little BTW at the end. Gary Gilbert has posted his experiences with installing Railo/Resin/Apache under CentOS.
Here you can read his entries:
Part 1
Part 2

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Gert Franz's Gravatar If you need the document as a pdf, you can download it here:
http://dev.railo.ch/documentation/Railo_on_CentOS....
Gert
# Posted By Gert Franz | 12.11.08 04:47
nooree's Gravatar I can't download above pdf. s(_ _ ')a
# Posted By nooree | 12.11.08 15:10
Tom Chiverton's Gravatar Excellent tips.
One minor nit is that it's normally better to create a file in /etc/httpd/conf.d/ than edit than httpd.conf directly.
# Posted By Tom Chiverton | 12.11.08 15:49
# Posted By Gert Franz | 12.11.08 15:51
Who Cares?'s Gravatar Tom, there's no editing of the httpd.conf. The entries are added automatically by the "make install" process. Of course it would be better to have them separated out into their own <whatever>.conf. But then, that's Resin stuff and thus not a responsibility of the Railo team ;)
Also, it's actually much nicer to have the stuff in your vhost configuration files. By moving it there, you can have seperate Resin/Railo clusters working with different setups for different virtual hosts on your system.
# Posted By Who Cares? | 12.11.08 23:57
Bob's Gravatar Top download didn't work since there were too many slashes after the http:
# Posted By Bob | 13.11.08 17:09
Gert Franz's Gravatar Right, my fault. I corrected it.

Thanks for the hint.

Gert
# Posted By Gert Franz | 13.11.08 17:42
Tom Chiverton's Gravatar @Who cares?
I spoke of 'editing' in the sense of what the installer does. Directly modifing httpd.conf is more likely to be broken by O/S package updates than using conf.d or (like you say say) an include in each vhost.d that needs CFML support.
# Posted By Tom Chiverton | 18.11.08 17:39
hungry's Gravatar in the section about adding virtual hosts you left off a closing tag for web-app.
i don't know how code shows up in comments...but line should read
<pre><web-app id="/" root-directory="railo.hostek.com"/></pre>
# Posted By hungry | 04.12.08 09:31
Gert Franz's Gravatar Right... I have just corrected that.

Thanks for the hint.

Gert
# Posted By Gert Franz | 04.12.08 12:50
Roy Ing's Gravatar Gert: Great tutorial. On my CentOS 5.2 installation, Railo works but does not start running automatically on reboot. In System->Administration->Server->Settings->Services, the right panel under Status shows "unknown argument 'status'" for the service Resin. Should there be a 'status' argument for the Resin script (in addition to 'start', 'stop' and 'restart')? For example, here is an article about using chkconfig that shows 'status' as an expected argument:
http://www.rpm-based.org/how-to-manage-services-wi...
# Posted By Roy Ing | 11.01.09 16:35
Todd Rafferty's Gravatar To anyone needing assistance, if you by some chance come across a weird error running the ./httpd.sh script - The last comment on this post ( http://www.hockeypfef.net/index.cfm/2008/9/29/Rail... ) shows you how to fix it.
# Posted By Todd Rafferty | 15.01.09 22:59
Nicholas's Gravatar I had started resin like this.
[root@linux httpd]# /opt/soft/railo/bin/httpd.sh start
Resin/3.1.2 started -server ''.
Tested ok
[root@linux httpd]# cd /etc/httpd
[root@linux httpd]# apachectl -t
Syntax OK
Restarted httpd
[root@linux httpd]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
Created the files in conf.d and checking caucho-status and it says localhost:6800(down)
Status : Caucho Servlet Engine
Start Time Sat Feb 14 19:52:39 2009
Now Sat Feb 14 19:53:04 2009
Session Cookie 'JSESSIONID'
Session URL ';jsessionid='
Config Check Interval 15s
Config Cache File /tmp/localhost_6800
Configuration Cluster
Host Active Pooled Connect
Timeout Live
Time Dead
Time
1. localhost:6800 (down) 0 0 2 10 120
Unconfigured Default Virtual Host
Source: unconfigured
Last-Update: Thu Jan 1 07:30:00 1970
Host Active Pooled Connect
Timeout Live
Time Dead
Time
web-app url-pattern
Please help.
Thanks!
# Posted By Nicholas | 14.02.09 04:55
Nicholas's Gravatar Hi,

Managed to setup resin and railo successfully.

I have no problem logging into http://192.168.1.20:8600/railo-context/admin/index.cfm" target="_blank">http://192.168.1.20:8600/railo-context/admin/index...

But if i go to http://192.168.1.20, i encountered a 503 error.

Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.


--------------------------------------------------------------------------------

Apache/2.2.3 (CentOS) Server at 192.168.1.20 Port 80

Please help!
# Posted By Nicholas | 14.02.09 07:01
jj's Gravatar @Nichoclas
check your httpd.conf mod_caucho settings
the ResinConfigServer setting must be the same port than in resin.conf
<!-- define the servers in the cluster -->
<!--server id="a" address="127.0.0.1" port="68XX" />
# Posted By jj | 14.02.09 12:19
Nicholas's Gravatar in httpd.conf

LoadModule caucho_module /usr/lib/httpd/modules/mod_caucho.so
ResinConfigServer localhost 8600
CauchoConfigCacheDirectory /tmp
CauchoStatus yes

in resin.conf

<cluster id="app-tier">
<!-- sets the content root for the cluster, relative to server.root -->
<root-directory>.</root-directory>

<server-default>
<!-- The http port -->
<http address="*" port="8600"/>

......
......
......
......

<!--
- If starting bin/resin as root on Unix, specify the user name
- and group name for the web server user.
-
- <user-name>resin</user-name>
- <group-name>resin</group-name>
-->
</server-default>

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

All the ports are 8600

What else should i check for?
# Posted By Nicholas | 14.02.09 15:27
misty's Gravatar Hi,

I have apache2 installed on ubuntu 8.10 and have CF applications I want to run.

Do I necessarily HAVE to have resin installed to get railo to work or will apache2 work wth railo without resin?

Can't seem to find this answer.

Thx
# Posted By misty | 19.02.09 21:27
Gert Franz's Gravatar Misty,

Apache is a Webserver which has limited capabilities of delivering dynamic web pages. What you need for this is an application server like JRun, Tomcat, Jetty or in Railo's case Resin.

So yes it is necessary to install Resin. Railo is running on top of Resin.

Gert
# Posted By Gert Franz | 20.02.09 07:59
Andrew Penhorwood's Gravatar When installing Railo on CentOS along with Apache make sure to turn off SELinux or alter the SELinux configuration (don't have a clue how to do that yet). I had Apache working and Resin / Railo working but when I turned on mod_caucho Apache stopped working. I was only getting 503 errors on any request to Apache. I switched SELinux into permissive mode and everything started working.

The great people from Railo pointed me in the right direction.
# Posted By Andrew Penhorwood | 24.02.09 14:12
Ryan's Gravatar The community version of this product is very exciting. We are rushing to prototype using the above method. Coming from Win 2003 we are having a devil of a time getting the getting virtual directories configured though. Are any changes required in the httpd.conf file? or do we just need to make the changes in the resin.conf.
# Posted By Ryan | 25.03.09 22:39
prem's Gravatar @Nicholas,
I had the same problem, fixed the issue by removing the old mappings to java and created new mapping to jdk1.6, and then configuire/make and install. Then restart resin and apache. it should work. As suggested make the SELinux level as permissive.

great blog keep up the good work. and Thank you...
# Posted By prem | 15.04.09 15:17
Web Design Lancaster's Gravatar I can't tell you how much I appreciate these instructions. I got Railo running on my slice and it purrs along beautifully. I had some performance issues at first, but then I upgraded to a 512 slice and all is working well. Thanks a lot!
# Posted By Web Design Lancaster | 24.07.09 12:41
Update problems's Gravatar I updated my system to Centos 5.2 everything worked fine however my sites that was done in Mura CMS under the Resin railo does not show any more. I can not get the Caoucho-status page to show, I can get the railo pages to show web adminstrator and server administrator to show.I tried restarting resin/railo and still same problem. Any Ideas
# Posted By Update problems | 28.09.09 16:12
Gert Franz's Gravatar Update problems,

what you can do is to either ask your question on the mailing list of Railo or Mura or ask for professional support by contacting us over the www.getrailo.com website. There can be hundred reasons why something is wrong...



Greetings from Switzerland
Gert Franz

Railo Technologies   Professional Open Source
skype: gert.franz   gert@getrailo.com
+41 76 5680 231   www.getrailo.com
# Posted By Gert Franz | 28.09.09 16:24
Update problems's Gravatar Ok. I will try that, I think my problems is with bind issues, it states when I look at Resin startup process Can't bind to /127.0.0.1:68. So that might be my problem. Thanks.
# Posted By Update problems | 28.09.09 17:19
Gert Franz's Gravatar Well this might mean that you have something running on port 6800...

Try and check that first. (Maybe another instance of Railo?)
# Posted By Gert Franz | 28.09.09 18:09
Cris Rhea's Gravatar Couple things:
1. Add the location handler for /caucho-status BEFORE restarting the httpd service.
2. As of railo-3.1.1 and Resin 3.1.2, the contrib/init.resin file IS NOT CORRECT.
A. "-pid $PID" is not a valid argument
B. "start"/"stop" should be after $ARGS
C. "-java_home" is not a valid argument
D. "-resin_home" should be "-resin-home"
E. The "$PID" file is no longer created, so remove all code referencing it.
My /etc/init.d/resin file looks like:
#!/bin/sh
#
# Linux startup script for Resin
#
# chkconfig: 345 85 15
# description: Resin is a Java Web server.
# processname: wrapper.pl
#
# To install, configure this file as needed and copy init.resin
# to /etc/rc.d/init.d as resin. Then use "# /sbin/chkconfig resin reset"
#
JAVA_HOME=/usr/java/latest
RESIN_HOME=/kaizen1/railo
export JAVA_HOME RESIN_HOME
#
# If you want to start the entire Resin process as a different user,
# set this to the user name. If you need to bind to a protected port,
# e.g. port 80, you can't use USER, but will need to use bin/resin.
#
USER=
#
# You can change this to $RESIN_HOME/bin/resin if you need Resin to
# bind to port 80, but run as a different user.
#
EXE=$RESIN_HOME/bin/httpd.sh
#
# Sets the commandline arguments.
#
ARGS="-resin-home $RESIN_HOME"
case "$1" in
start)
echo -n "Starting resin: "
if test -n "$USER"; then
su $USER -c "$EXE $ARGS start"
else
$EXE $ARGS start
fi
echo
;;
stop)
echo -n "Shutting down resin: "
$EXE stop
echo
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
# Posted By Cris Rhea | 28.09.09 23:26
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact Blog Owner