Setting up Apache, OpenBD, Railo and ColdFusion - Part 2 - Installing Tomcat/Apache/OpenBD

ColdFusion, Linux

This is the second part in a series of posts on setting up ColdFusion, OpenBlueDragon, and Railo all on the same machine using Apache webserver to listen for all requests and direct traffic.  Part 1 can be found here

Remember, the steps below have some commands specific to Linux, and more specifically to Debian/Ubuntu, but the concepts in general should have at least some similarites across any supported platform, especially you Mac folks.

 

To start out, we need to make sure that we have the Apache webserver installed with optional "dev" package.  Additionally, later on we will need to be compiling, so let's make sure that you have the build-essential package as well

$sudo apt-get install apache2 apache2-threaded-dev build-essential
Next I installed the Sun Java 6 JDK
$sudo apt-get install sun-java6-jdk

Next you want to go download Tomcat.  I chose to use Tomcat 6, specifically v. 6.0.18, which the current release as of this posting.  Now, using a terminal cd into the directory where you saved the dowloaded file and do the following:

$ sudo cp apache-tomcat-6.0.18.tar.gz /opt/ 
$ cd /opt 
$ sudo tar xvzf apache-tomcat-6.0.18.tar.gz 
$ sudo mv apache-tomcat-6.0.18 tomcat6 
$ sudo rm apache-tomcat-6.0.18.tar.gz


Next we will need to edit the Tomcat startup script, but to do so, we need to go get a little information first.  We need to ensure that we know what the current Java home is on your machine.  There are surely easier ways of accomplishing this, but here is the series of steps I took.
~$ which java
/usr/bin/java 
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2009-01-30 23:00 /usr/bin/java -> /etc/alternatives/java 
$ ls -l /etc/alternatives/java[return] lrwxrwxrwx 1 root root 36 2009-01-30 23:00 /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/jre/bin/java 


From that last line I can see that the default Java lives at /usr/lib/jvm/java-6-sun/ (which too is a sym link, but that's ok!). Now that we have our Java home we can edit the Tomcat startup script
$sudo gedit /opt/tomcat6/bin/catalina.sh


Paste the following lines in just after the big comment block at the top. Make sure that if your Java path looked different than mine did, you will want to adjust accordingly.
JAVA_HOME=/usr/lib/jvm/java-6-sun 
JRE_HOME=/usr/lib/jvm/java-6-sun/jre 
JAVA_OPTS="-server -Xms1024M -Xmx1024M -XX:PermSize=256m -XX:MaxPermSize=256m \
    -Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8 \
    -Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl" 	


Now we want to download the Apache Tomcat connector source so that we can pass requests from Apache webserver to Tomcat. This is the one I grabbed: http://apache.org/dist/tomcat/tomcat-connectors/jk/source/ Next you will want to browse to the directory that you downloaded that file into using in the terminal. Next run:
$ tar xvzf tomcat-connectors-current-src.tar.gz 
$ cd tomcat-connectors-1.2.27-src/native 
$ ./configure --with-apxs=/usr/bin/apxs2 
$ make 
$ sudo make install


Now we will need to create a jk mod file to be included by Apache so that it loads the adapter when Apache starts. In your terminal cd to /etc/apache2/mods-available. In this directory we will create a file named jk.load.
$sudo gedit jk.load


In that file pasted the following, then save and exit:
LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so  
# Where to find workers.properties 
# Update this path to match your conf directory location (put workers.properties next to httpd.conf) 
JkWorkersFile /etc/apache2/workers.properties 
# Where to put jk shared memory 
# Update this path to match your local state directory or logs directory 
JkShmFile     /var/log/apache2/mod_jk.shm 
# Where to put jk logs 
# Update this path to match your logs directory location (put mod_jk.log next to access_log) 
JkLogFile     /var/log/apache2/mod_jk.log 
# Set the jk log level [debug/error/info] 
JkLogLevel    info 
# Select the timestamp log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "


Now we want to create a symbolic link to this file in /etc/apache2/mods-enabled so that it is loaded when Apache starts.
$ cd /etc/apache2/mods-enabled 
$ sudo ln -s ../mods-available/jk.load ./jk.load 


Next we want to create a virtual host in Apache to catch the requests. We are going to create a new file in the sites-available directory.
$ cd /etc/apache2/sites-available 
$ sudo gedit localhost.bd 
In that file, paste the following, save, and exit:
<VirtualHost *>
	ServerName localhost.bd
	JKMount /* worker1
</VirtualHost> 


Now we need to create a symbolic link to that file from sites-enabled so that it is available when apache2 starts.
$ cd /etc/apache2/sites-enabled 
$ sudo ln -s ../sites-available/localhost.bd ./001-localhost.bd


Next we want to make sure that we can get to that site in a browser, so we are going to add 'localhost.bd' to our hosts file. Open up /etc/hosts, and append 'localhost.bd' (without quotes!) to the line that begins with 127.0.0.1. Now we need to define that "worker1" that we just referenced above in the VirtualHost definition. We will do that by creating a workers.properties file in our apache2 directory.
$ cd /etc/apache2 
$ sudo gedit workers.properties


Insert the following. Then save and exit:
# Define 1 real worker using ajp13 
worker.list=worker1 
# Set properties for worker1 (ajp13) 
worker.worker1.type=ajp13 
worker.worker1.host=localhost.bd 
worker.worker1.port=8009  


Next we want to create a webapp in Tomcat for Apache to send to.
sudo gedit /opt/tomcat6/conf/server.xml
In that config, we need to define the localhost.bd site, or 'webapp'. Add the following:
<Host name="localhost.bd"  appBase="webapps"
      unpackWARs="true" autoDeploy="true"
      xmlValidation="true" xmlNamespaceAware="false">	
	<Context path="" docBase="localhost.bd/" reloadable="true" privileged="true" antiResourceLocking="false" anitJARLocking="false">
	</Context>
</Host>


Now we need to create the local.bd directory under Tomcat. Note: as you get more comfortable and adventurous, you may want this to be a symbolic link to another place on your machine where your source resides, but for now we are keeping it as simple as we can. Once the directory is created, we will download the OpenBlueDragon war file and extract it.
$ sudo mkdir /opt/tomcat6/webapps/localhost.bd
$ cd /opt/tomcat6/webapps/localhost.bd 
$ sudo wget http://openbd.viviotech.net/downloader.cfm/id/64/file/openbd.war 
$ sudo jar xvf openbd.war 


And with that step, and after restarting Apache, and starting Tomcat, OpenBlueDragon will now be available.
$ sudo /etc/init.d/apache2 restart 
$ /opt/tomcat6/bin/catalina.sh start


Open up your browser and go to: http://localhost.bd/bluedragon/administrator

You should be created with your OpenBD admin page like this:

 

Next: Part 3 - Installing ColdFusion 8 and customizing the JRun connector

 
I believe instead of manually creating the symlinks you can use a2ensite and a2enmod for the apache mods. Great reference for setting up all 3 (dominant) CF engines though. I feel like I'm seeing Railo and Open BD pop up everywhere now.
 
posted 292 days ago
View Replies (1) || Add Comment Reply to: this comment OR this thread
 
.: HIDE REPLIES :.
 
Cool, I never knew about a2[en/dis][site/mod]!

However, I will probably only use them for mods rather than the sites as I like to give numbers to the sites so that they are loaded in a particular order. When working with the development InstantSpot for instance, if it loads ahead of others it will try to grab all requests since it doesn't listen for a specific ServerName.

Thanks for the tip Paul.
 
posted 292 days ago
Add Comment Reply to: this comment OR this thread
 
Jonathan van Zuijlekom said:
 
Tomcat 6.0.18 and modJK are in the Ubuntu reposities.

"sudo apt-get install tomcat6 libapache2-mod-jk"
 
posted 291 days ago
View Replies (3) || Add Comment Reply to: this comment OR this thread
 
.: HIDE REPLIES :.
 
Yeah, when I was talking to Aaron yesterday morning after posting this, I said "I have no idea why I compiled Tomcat from source....oh well." :)

I might revise this later.
 
posted 291 days ago
Add Comment Reply to: this comment OR this thread
 
Jonathan van Zuijlekom said:
 
What's sweet about this setup is that with a symbolic link I can test my sources with CF, OpenBD and Railo at the same time :)
 
posted 291 days ago
Add Comment Reply to: this comment OR this thread
 
 
The only caveat to that, which is pretty minor IMO, is that you will need to maintain separate WEB-INF directories for your OpenBD test and your Railo test. At least the way I do it that is true. Perhaps someone can steer to a better approach there.
 
posted 291 days ago
Add Comment Reply to: this comment OR this thread
 
Jonathan van Zuijlekom said:
 
I allso had to edit my /etc/tomcat6/policy.d/
03catalina.policy file and grant permissions to catalina


grant codeBase "file:/var/lib/tomcat6/webapps/localhost.bd/WEB-INF/lib/-" {
permission java.security.AllPermission;
};
 
posted 267 days ago
Add Comment Reply to: this comment OR this thread
 
Jonathan van Zuijlekom said:
 
I had a problem that Tomcat wasn't serving anything other then cfm pages, so no .css .jpg etc.
What I did was change one line and adding on line in de site-availible/localhost.bd:
DocumentRoot /var/lib/tomcat6/webapps/localhost.bd
JKMount /*.cfm worker1

Now apache takes care of serving al
 
posted 267 days ago
Add Comment Reply to: this comment OR this thread
 
wow gold said:
 
 
posted 210 days ago
Add Comment Reply to: this comment OR this thread
 
chris hough said:
 
Hello Dave, first, I would like to thank you for the excellent guide I am modeling my build off of, but I have a few questions that I just posted on server fault that I am wonder if you could help me with: http://serverfault.com/questions/58225/tomcat-site...

If you could point me in the right direction or offer any insight that would be awesome.
 
posted 89 days ago
Add Comment Reply to: this comment OR this thread
 
 
Chris one initial thought is to take a look at the FollowSymlinks directive in the apache config. I have had some issues previously with symbolically linked files not being available until I added that.
 
posted 88 days ago
View Replies (1) || Add Comment Reply to: this comment OR this thread
 
.: HIDE REPLIES :.
chris hough said:
 
currently I am using:


Options FollowSymLinks
AllowOverride None
#XAMPP
#Order deny,allow
#Deny from all


but I think its more than that, I created a symlink in the directory back to the WEB-INF for openBD and the file work, and I bet if I created a link to bluedragon the admin would come up.

ideally i think it would be nice to set it up like the theory I posted at servefault, but I am still trying to find out how, or if it as at all possible

http://serverfault.com/questions/58225/tomcat-site...
 
posted 88 days ago
Add Comment Reply to: this comment OR this thread
 
jbuda said:
 
i have managed to get this all working now. When i want to add a website where would it go? If i wanted to test the site on Railo and on Coldfusion, would i need to duplicate the site (and have 2) and put into the relevant web roots, thus creating 2 different virtual hosts (one for Railo and one for CF8?)
 
posted 86 days ago
Add Comment Reply to: this comment OR this thread
 
Violet said:
 
Thanks for explanation. I believe you are genious! It seems to me that you follow the principle: if it doesn't exist - then creat it. And I'm only the beginner in programming. Found a lot of nice books at the book search engine http://pdf.rapid4me.com . And now I'm looking for examples. To tell the truth, your work inspires me greatly.
 
posted 10 days ago
Add Comment Reply to: this comment OR this thread
 

Search