Railo Server and Apache
A few weeks ago I got a VPS from KickAssVPS. I decided to go with a Linux (CentOS 5) box and install Railo 3. However, after googling, I have found out that there is very little info on how to integrate Railo 3 with apache. So I decided to create this step by step solution that worked for me. I would like to give a big thanks to the Railo Support team, especially Joachim Koenig. He was a great deal of help.
The first step you have to do is, of course, install CentOS 5 with apache. There are many guides on the web on how to do this but if you are a newbie, I suggest going to http://www.howtoforge.com.
Before you go any further, you will need the following: a Java-runtime environment (comes with Railo) Perl gcc httpd-devel-i386 Download the Railo-archive (including Resin and JRE) from the website http://www.railo.ch
$ wget http://www.railo-technologies.com/down.cfm?item=/railo/remote/download/3.0.0.005/server/unix/railo-3.0.0.005-resin-3.1.2-with-jre-linux.tar.gz
and copy/move it as root to /opt, in order to unpack it there. Since the unpacking of the archive generates a long directory name, we create a symbolic link with the name "railo", which will point to the future productive version.
$ mv railo*.tar.gz /opt
$ tar -xzf railo*.tar.gz
$ ln -s railo-3.0.0.005-resin-3.1.2-with-jre-linux railo
Unnecessary files can be deleted:
$ rm railo*.tar.gz
$ cd railo
$ rm -rf httpd.exe install-service.bat remove-service.bat setup.exe win32
Go to your railo-server directory
$ cd /opt/railo
$ ./configure --with-apxs=/usr/sbin/apxs –with-java-home=/opt/railo/jre
$ make
$ make install
That will make the module (mod_caucho.so). Copy it into your /usr/lib/httpd/modules and add
# mod_caucho Resin Configuration
LoadModule caucho_module /usr/lib/httpd/modules/mod_caucho.so
ResinConfigServer localhost 6800
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
to your /etc/httpd/conf/httpd.conf
Configuring the webs in resin.conf
Edit the file /opt/railo/conf/resin.conf – Enter the mapping pointing to your host:
mysite-two.com
/path/to/web/files
Check http://your-ip/caucho-status to see if the module is loaded and resin runs you will see something like this
######
Status : Caucho Servlet Engine
Start Time Mon Sep 15 11:00:21 2008
Now Tue Sep 16 19:55:42 2008
Session Cookie 'JSESSIONID'
Session URL ';jsessionid='
Config Check Interval 600s
Config Cache File /tmp/172.16.198.63_6801
Configuration Cluster
Host Active Pooled Connect
Timeout Idle
Time Recover
Time
1. 172.16.198.63:6801 (ok) 0 1 2 10 15
2. 172.16.198.64:6801 (ok) 0 1 2 10 15
#####
if everything is green the apache resin config is OK
To get to the Railo Administrator: http://www.mysite-two.com:8080/railo-context/admin.cfm
In /opt/railo/contrib/ there is a sample init script
adapt it
cp sample-script /etc/init.d/resin
chkconfig resin on
Start up script that I used:
##############################################
#!/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=/your/usr/java/home_DIR
RESIN_HOME=/your/resin/home_DIR
export JAVA_HOME RESIN_HOME
JAVA=$JAVA_HOME/bin/java
#
# 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=
#
# Set to the server id to start
#
#SERVER="-server app-a"
#
ARGS="-resin-home $RESIN_HOME $SERVER"
if test -r /lib/lsb/init-functions; then
. /lib/lsb/init-functions
else
log_daemon_msg () {
if [ -z "$1" ]; then
return 1
fi
if [ -z "$2" ]; then
echo -n "$1:"
return
fi
echo -n "$1: $2"
}
log_end_msg () {
[ -z "$1" ] && return 1
if [ $1 -eq 0 ]; then
echo " ."
else
echo " failed!"
fi
return $1
}
fi
case "$1" in
start)
logger "Starting resin"
if test -n "$USER"; then
su $USER -c "$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS start" 1>/dev/null 2>/dev/null
else
$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS start 1>/dev/null 2>/dev/null
fi
logger $?
;;
stop)
logger "Stopping resin"
if test -n "$USER"; then
su $USER -c "$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS stop" 1>/dev/null 2>/dev/null
else
$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS stop 1>/dev/null 2>/dev/null
fi
logger $?
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
Any questions or suggestions let me know.
Comments
Cory wrote on 12/12/08 1:01 AM
hey thanks a lot for posting this! it really helped clear up my misunderstanding of the paths for 'web context' and 'doc root', as defined in the resin.conf file. it's not explained very well in the documentation, and coming from a non-java background, I had to do a little speed learning tooyou are very correct: there is little or no linux info on railo configuration online. seems to be mostly windows/IIS. maybe this will change as more people are adopting the open source version?
Ken wrote on 01/10/09 1:07 PM
Same problem as Tim. Anyone figured out how to correct this problem?[root@localhost railo]# bin/httpd.sh start
conf/resin.conf:5: java.lang.NoSuchMethodError: method java.lang.Class.isAnnotationPresent with signature (Ljava.lang.Class;)Z was not found.
3: -->
4: <resin xmlns="http://caucho.com/ns/resin";
5: xmlns:resin="http://caucho.com/ns/resin/core">;
6:
7: <!-- adds all .jar files under the resin/lib directory -->
Ken wrote on 01/11/09 3:08 PM
I figured out how to fix the problem that Tim and I werehaving:
First, ensure that you have the java JDK installed (not
just the JRE). Open httpd.sh (path is
/opt/soft/railo/bin/httpd.sh for me) and change
"java=java" to "java=/opt/soft/java/bin/java".
Save the change and you're done.
Nicholas wrote on 02/14/09 1:55 AM
I think i had installed resin successfully.checking caucho-status, it says down.
http://192.168.1.20/caucho-status
Status : Caucho Servlet Engine
Start Time Sat Feb 14 20:13:52 2009
Now Sat Feb 14 20:53:17 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
2. localhost:6802 (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
--------------------------------------------------------------------------------
Resin/3.1.2
If i go to the default page of the server
http://192.168.1.20/
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
Can anyone help? Thanks
Nicholas wrote on 02/14/09 2:58 AM
Sorry. I messed up the port. Should be 8600. Now its says1. localhost:8600 (ok) 0 0 2 10 120
But i still getting the 503 error
http://192.168.1.20
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
Jason Haritou wrote on 03/29/09 2:25 PM
Is the Resin server actually running? Type# /opt/railo/bin/httpd.sh
and then try the page again.
HTH

Tim wrote on 11/26/08 11:08 PM
Hi wondering if you or anyone else has ever run into this problem, I'm trying to install Railo on Red Hat EL5. I have JDK 1.6 installed. Apache 2.2 installed. I follow the directions here but when I got to start resin, I get this error. Any ideas?[root@localhost railo]# bin/httpd.sh start
conf/resin.conf:5: java.lang.NoSuchMethodError: method java.lang.Class.isAnnotationPresent with signature (Ljava.lang.Class;)Z was not found.
3: -->
4: <resin xmlns="http://caucho.com/ns/resin"
5: xmlns:resin="http://caucho.com/ns/resin/core">
6:
7: <!-- adds all .jar files under the resin/lib directory -->