Skip to content

Instantly share code, notes, and snippets.

@ryanguill
Last active November 26, 2019 13:03
Show Gist options
  • Save ryanguill/7929115 to your computer and use it in GitHub Desktop.
Save ryanguill/7929115 to your computer and use it in GitHub Desktop.

Preface

This guide is one section of a larger guide to installing a cent 6.x server in virtual box for development purposes with different applications. The top level guide with links to all of the sections is here: https://gist.github.com/ryanguill/5149058 Some instructions in this guide may assume a configuration from other parts of the guide.

#Install Railo ColdFusion - manual installation

These instructions assume you are starting with a new VM cloned from your template

##Install httpd

Use these instructions to install httpd: https://gist.github.com/ryanguill/7928972 Settings below will assume the same settings.

##Install tomcat Use these instructions to install tomcat: https://gist.github.com/ryanguill/7929048 Settings below will assume the same settings.

Install Railo

There are several ways to install railo. I've tried a few and this seems to be the best way, it gives you the most options down the road. It might not be appropriate for a dev machine where you want to install multiple versions of railo, or railo along with ACF or any other servlet. This should be the best way to do it for servers though.

Ive used lots of pieces from lots of people to come up with this setup. Links at the end.

Download Railo:

Go to http://www.getrailo.org/index.cfm/download/ and copy the link for railo custom: jar files tar.gz

Note: as of this writing Railo is version 4.1.1.009

Make sure you are root and in your home directory:

#su -
#cd ~

Download railo: (You might want to change the thankyou url parameter to false for this)

# wget http://www.getrailo.org/down.cfm?item=/railo/remote/download/4.1.1.009/custom/all/railo-4.1.1.009-jars.tar.gz&thankyou=false

Make a railo directory in your tomcat directory to hold the extracted jars

# mkdir -m 755 $CATALINA_HOME/railo

Extract the jars

# tar xvzf ~/railo-4.1.1.009-jars.tar.gz -C ~/
# cp -r railo-4.1.1.009-jars/* $CATALINA_HOME/railo
# cd $CATALINA_HOME/railo && ls -la

You should see a bunch of jars.

Now lets change our catalina.properties file

# vi $CATALINA_HOME/conf/catalina.properties

find the line that says common.loader

/common.loader

It will look something like this

common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar

Add the following to the end of the line

,${catalina.home}/railo/*.jar

So that it looks like this

common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/railo/*.jar

save and close catalina.properties

[esc] :x

Open web.xml

# vi $CATALINA_HOME/conf/web.xml

Find the first

/<servlet>

It will probably be default. After that , add the following

  <!-- The GlobalCFMLServlet and the GlobalAMFServlet are provided by       -->
  <!-- railo.  See http://www.getrailo.org/ and $CATALINA_HOME/railo        -->

<servlet>
	<servlet-name>GlobalCFMLServlet</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-root-directory}/WEB-INF/railo/</param-value>
		<description>Configuraton directory</description>
	</init-param>    
	<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
	<servlet-name>GlobalAMFServlet</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>

Then find 's

/<servlet-mapping>

Then paste these after the ones already set up

  <!-- railo servlet mappings -->

<servlet-mapping>
	<servlet-name>GlobalCFMLServlet</servlet-name>
	<url-pattern>*.cfm</url-pattern>
</servlet-mapping>
<servlet-mapping>
	<servlet-name>GlobalCFMLServlet</servlet-name>
	<url-pattern>/index.cfm/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
	<servlet-name>GlobalCFMLServlet</servlet-name>
	<url-pattern>*.cfml</url-pattern>
</servlet-mapping>
<servlet-mapping>
	<servlet-name>GlobalCFMLServlet</servlet-name>
	<url-pattern>*.cfc</url-pattern>
</servlet-mapping>
<servlet-mapping>
	<servlet-name>GlobalAMFServlet</servlet-name>
	<url-pattern>/flashservices/gateway/*</url-pattern>
</servlet-mapping>	

Note: if you are going to want to install your application (or multiple applications) as subdirectories under the webroot, such as http://site.local/app/index.cfm, you will need to add a url-pattern for each subdirectory (apparently tomcat only allows one wildcard in their url-patterns.). So for an application named "app", find the servlet-mapping with the url-pattern of /index.cfm/* and add a new url-pattern underneath it for the application, so it will look like this:

<servlet-mapping>
	<servlet-name>GlobalCFMLServlet</servlet-name>
	<url-pattern>/index.cfm/*</url-pattern>
	<url-pattern>/app/index.cfm/*</url-pattern>
</servlet-mapping>

for another example, if you had an application like "mobile" it would be

<url-pattern>/mobile/index.cfm/*</url-pattern>

now find the and add an index.cfm entry

/<welcome-file-list>

Add this:

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

save and close web.xml

now open server.xml

# vi $CATALINA_HOME/conf/server.xml

Find the tags that are already there and add the following below: (make sure the name matches your sever name)

<Host name="cent6-railo.local" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
	<Context path="" docBase="/data/www" />
</Host>

Save and exit.

Start tomcat

# service tomcat start

Now we need to make edits to the httpd.conf file. This assumes you already have httpd installed and configured according to the instructions above.

# vi /etc/httpd/conf/httpd.conf

Ensure that you have the right modules loaded. Make sure these are uncommented: (They should already be) Note: they will not be next to each other in the file, or in this order more than likely

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule rewrite_module modules/mod_rewrite.so

Note: This guide assumes that you are only going to run one application on this server. If you need multiple virtual hosts you may need to change some of the following settings. I hope to expand these instructions later to cover that case.

Turn on NameVirtualHosts - Find the line that says

NameVirtualHost *:80

And make sure it is uncommented.

Go to the very bottom (I like to leave the example virtual host there and commented out) and paste in this virtual host declaration: Note: make sure you change everything that says cent6-railo.local to your sever name, or to the name of this virtual host if you are using multiple virtual hosts

<VirtualHost *:80>
	ServerName cent6-railo.local
	DocumentRoot "/data/www"
	
	#LogLevel Debug
	ErrorLog "logs/cent6-railo.local-error.log"
	CustomLog "logs/cent6-railo.local-access.log" common
	
	ProxyPreserveHost On
	ProxyPassReverse / ajp://localhost:8009/
	#dont use proxy pass, use mod_rewrite rules
	#ProxyPass / ajp://localhost:8009/
	
	RewriteEngine On
	
	# dynamic handling of robots.txt:
	#RewriteRule ^/robots.txt ajp://localhost:8009/index.cfm/main/robots [P,L]
   
	# handle static assets without rewrite:
	RewriteRule ^.*\.(bmp|BMP|gif|GIF|htc|html?|jpe?g|JPE?G|ico|png|PNG|svg|css|js|wav|mp3|swf|txt|pdf|doc|xls|xml)$ - [L]
   
	# pass jsp heartbeat request thru directly:
	RewriteRule ^/probe/heartbeat.jsp$ ajp://localhost:8009/probe/heartbeat.jsp [P,L]

	# pass site root request thru directly:
	RewriteRule ^/?$ ajp://localhost:8009/ [P,L]

	# pass test and admin requests thru directly:
	RewriteRule ^/(mxunit|tests|railo-context)/(.*)$ ajp://localhost:8009/$1/$2 [P,L]

	# pass all .cfm / .cfc requests thru:
	RewriteRule ^/(.*\.cf[cm].*)$ ajp://localhost:8009/$1 [P,L]

	# pass all others thru as assumed routes:
	#RewriteRule ^/api(/.*)$ ajp://localhost:8009/api/index.cfm$1 [P,L]
	#RewriteRule ^/mobile(/.*)$ ajp://localhost:8009/mobile/index.cfm$1 [P,L]
	
	#use this instead of the last rule if you want to use SES URL's in fw/1
	#RewriteRule ^/(.*)$ ajp://localhost:8009/index.cfm/$1 [P,L]
	
	RewriteRule ^/(.*)$ ajp://localhost:8009/$1 [P,L]
			
	<Directory "/data/www">
		Options Indexes FollowSymLinks
		AllowOverride None
		Order allow,deny
		Allow from all
	</Directory>
	
</VirtualHost>	

save and exit. restart httpd

service httpd restart

Now I like to create a file like this and put it as index.cfm in /data/www to test that everything is working properly:

echo '<cfdump var="#now()#" /><br /><cfdump var="#server#" /><br /><cfdump var="#cgi#" />' >> /data/www/index.cfm

Now you should be able to hit the server from port 80 from outside of the VM and get the dumps we just created. This make take some time the first time, because railo is creating the web context. Subsequent requests should be fast.

http://cent6-railo.local

Now if you look in the /var/www directory, you should see a WEB-INF folder that has been created.

##setup the javaagent

check to see if you have a setenv.sh file in $CATALINA_HOME/bin/

if not, create it, then edit the file and add the following line: (check the path to the railo-inst.jar)

# vi setenv.sh

CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/apache-tomcat-7.0.50/railo/railo-inst.jar"

save and exit. The make the file executable

# chmod 755 setenv.sh

restart tomcat to pull in the changes

# service tomcat stop
# service tomcat start

Make sure tomcat is running. If not, check the path in the setenv.sh

# ps aux | grep tomcat

Don't forget to clean up after yourself in your home directory and remove any leftover files you no longer need.

Links and sources:

http://web-rat.com/blog/post.cfm/installing-railo-on-tomcat-the-windows-edition
http://kisdigital.wordpress.com/2011/11/16/adding-new-sites-to-railo-demystified/

#Install Railo ColdFusion (installer)

Note: I suggest using the manual instructions to install railo from above. I am only leaving these instructions here for posterity. Using these instructions will not result in the same configuration as the manual install instructions from above.

##Install httpd

Use these instructions to install httpd: https://gist.github.com/ryanguill/7928972 Settings below will assume the same settings.

Download English Linux 64-bit installer from http://www.getrailo.org/index.cfm/download/

You will have to download on your host system - then mount the user directory and drop the file in there

Make sure you are root # su -

Go to the user home

# cd /home/user
# ls -la

You should see your file. Chmod it and execute

# chmod 755 railo-4.0.4.001-pl0-linux-x64-installer.run
# ./railo-4.0.4.001-pl0-linux-x64-installer.run

Language Selection: 4 English - English

Accept license agreement

Installation Directory: Use the default /opt/railo

Tomcat user: use default: admin

Tomcat password: batman

Tomcat Web Server Port: use default: 8888

Tomcat Shutdown Port: use default 8005

Tomcat AJP Port: use default: 8009

Tomcat System User: root (yes, yes, I know - will likely change this later)

Start at Boot: Y

Install Apache Connector: Y

Apache Control Script Location: /usr/sbin/apachectl (default)

Apache Modules Directory: /usr/lib64/httpd/modules (default)

Apache Configuration File: /etc/httpd/conf/httpd.conf (default)

Apache Logs Directory: /var/log/httpd (default)

Bit Type: 2 64Bit

Continue: Y

We need to edit the webroot in the tomcat server.xml

# cp /opt/railo/tomcat/conf/server.xml /opt/railo/tomcat/conf/server.orig.xml
# vi /opt/railo/tomcat/conf/server.xml

Find the two Host tags at the bottom and add this inside the first one, and change the current context tag to look like this in the second

<Context path="" docBase="/data/www/" />

Restart Railo:

# service railo_ctl restart

Go to the administrator

http://<ipaddress>/railo-context/admin/web.cfm

create a test file to test out the cf install

# echo '<cfdump var="#server#" />' >> /data/www/server.cfm

cleanup after yourself

# rm /home/user/railo-4.0.4.001-pl0-linux-x64-installer.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment