The basics of installing Railo on Linux


With the advent of the automated installer, installing Railo has never been easier. However, the one thing I see quite often are permission errors because the Railo user does not have write access to the folders it needs access to. Please take everything I am about to say here with a grain of salt because this is my opinion of how things should be done. I have installed multiple systems and regardless which distribution you use it should work equally well.

Lets assume we have created a new stock installation of Linux. If I am logged in as root, the very first thing I do is create a new user account and make sure your account is in the sudoers file. Once that is accomplished login with your new user account and make sure you have access to sudo. If everything went well, go ahead and lock down your sshd configuration to block the root user from remote login. In this example my new username will be robert.

I will do a little forward thinking here. I like to host my websites in my home directory so I do not have to go digging through the file system when I want to add a web site. I like to keep things organized so I will create a folder in my home directory mkdir ~/sites. While I am at it, I may as well create a location for the default web site so I will also mkdir ~/sites/localhost.

Now comes the fun stuff. First we will need to install Apache. Assuming you are running a Debian distro this is as simple as running sudo apt-get install apache2. Since I plan on serving sites out of my home folder I am going to go ahead and set Apache to run as my user account. Depending on your distribution you will either find these set in your httpd.conf file or in the case of Deb based systems you can find these variables in /etc/apache2/envvars. Here are the lines I modified on my system in envvars:

export APACHE_RUN_USER=robert
export APACHE_RUN_GROUP=robert

With those changes made I saved the envvars file. While we are at it, lets go ahead and modify the default Apache host in /etc/apache2/sites-available/default:

<VirtualHost *:80>
 ServerAdmin webmaster@localhost
 ServerName localhost
 DocumentRoot /home/robert/sites/localhost
 DirectoryIndex index.cfm
 <Directory />
  Options FollowSymLinks
  AllowOverride None
 </Directory>
 <Directory /home/robert/sites/localhost/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
 </Directory>
 ErrorLog ${APACHE_LOG_DIR}/error.log
 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn
 CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Next I will use an editor and create /home/robert/sites/localhost/index.cfm. This is generally just a file with “It works” in it just to make sure everything is in working order and restart Apache with sudo service apache2 restart just to make sure all the changes I have made are in working order.

Now that has been accomplished I will grab the latest copy of the Railo installer. If I am not already in my home directory, I will cd to get back. Now I am ready to use wget to download the latest file with wget http://www.getrailo.org/down.cfm?item=/railo/remote/download/3.3.1.000/tomcat/linux/railo-3.3.1.000-pl1-linux-x64-installer.run. I generally grab the version that includes its own JRE because I have occasionally had issue with OpenJDK, again, this is my preference, your mileage may vary. Make the file you downloaded executable with chmod +x railo-3.3.1.000-pl1-linux-x64-installer.run and then run the installer. You must be root to run the file so, sudo ./railo-3.3.1.000-pl1-linux-x64-installer.run and you will be in business.

The Railo installer does a pretty good job of detecting your system and determining your default values for you. When Railo asks you what user to run Railo as I will choose my username (robert). Once the installer has finished doing its thing it is time to take a look at our installation and make sure everything is on the up and up. First, lets take a look at our Railo installation directory and make sure I own it by ls -la /opt.  If all went well it should show the railo directory owned by robert:robert. If not, I will make sure I own the directory with sudo chown -R robert:robert /opt/railo.

Once that has been done I generally edit my server.xml and point the default host localhost  docBase to my newly created locahost directory in ~/sites/localhost. This probably isn’t necessary, but I like keeping everything nice and homogeneous.

<Host name="127.0.0.1" appBase="webapps"
      unpackWARs="true" autoDeploy="true"
      xmlValidation="false" xmlNamespaceAware="false">
     <Context path="" docBase="/home/robert/sites/localhost" />
</Host>

Once that is completed, the only thing left to do is restart Railo with sudo /opt/railo/railo_ctl restart. If my changes were successful I should now see a WEB-INF folder in /home/robert/sites/localhost and by pointing my browser to the IP address of my server I should see my “It works!” page.

I suppose there is probably as many different configurations out there as there are admins. This configuration works fine for me as I am generally the only person working on my server. In situations where you have multiple users this is definitely not the best scenario and you would probably want a solution based on group permissions.

One thing I do see a lot that just makes me cringe are folks who run the Railo process as the root user. One one hand I could see where this would be beneficial since root has write access anywhere on the server and this does alleviate many issues folks new to Linux face. On the other hand, it can potentially be a huge security risk because if your web server is compromised the attacker holds the key to your kingdom (or server in this case). For this reason I always suggest running Railo on a non-privileged account.

Advertisements

About Robert Zehnder

Web application developer specializing in ColdFusion/Railo and Open Source development.

Posted on November 17, 2011, in Railo and tagged . Bookmark the permalink. 4 Comments.

  1. Great write up!! This may give me the incentive to tinker with Railo again!

    The best thing about this article is the wget to grab the Railo installer 🙂

    Oh how I wish Adobe would allow that!!

  2. Thanks Robert!

  1. Pingback: The basics of installing Railo on Linux « KISDigital Blog | Linux Supersaniya

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: