A web developing, photo taking, Muay Thai fighting man.

Installing Subversion 1.6.6 from source on Ubuntu 8.04

Posted: November 3rd, 2009 | Author: James | Filed under: linux | Tags: , , , | 6 Comments »

I’ve got a number of servers that are currently running the latest LTS release of Ubuntu, 8.04.  Unfortunately this release doesn’t have the latest version of subversion (1.6.6  at time of writing) available from apt and as the various clients that get used to access these working copies get updated, they stop working with the command line version on the server (1.5.1).

I found installing from source a bit fiddly at first but after some research managed to get everything hooked up as required.

Start off by grabbing the latest version from the subversion site and untar/gzipping it

wget http://subversion.tigris.org/downloads/subversion-1.6.6.tar.gz
tar xf subversion-1.6.6.tar.gz

There’s a few pre-requisites that need to be installed to compile subversion so if you’ve not already got them add these packages.

sudo apt-get install libc6-dev g++ gcc
sudo apt-get install libapr1 libapr1-dev libaprutil1 libaprutil1-dev libneon27 libneon27-dev

Configure the compilation from within the newly uncompressed directory and declare where you want the binaries to be saved to

./configure –prefix=/usr/bin/subversion-1.6.6 –disable-nls

And  finally run the make process

make
sudo make install

All being well you should have the latest version of subversion accessible from the directory you specified (in our case /usr/bin/subversion-1.6.6).  If you want this new version to precede the existing version so you don’t have to write in the full path each time.  Alter /etc/environment and add the path to the newly installed subversion to the start of the PATH variable. e.g.

PATH=”/usr/bin/subversion-1.6.6/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games”

Reload you environment file with

source /etc/environment

And type svn ––version to check that you do indeed have SVN 1.6.6 installed

svn, version 1.6.6 (r40053)
compiled Nov  3 2009, 12:19:16
Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
svn, version 1.6.6 (r40053)   compiled Nov  3 2009, 12:19:16
Copyright (C) 2000-2009 CollabNet.Subversion is open source software, see http://subversion.tigris.org/This product includes software developed by CollabNet (http://www.Collab.Net/).


Hosting Sites with Heavy Traffic on Amazon EC2

Posted: May 8th, 2009 | Author: James | Filed under: Web Development, Work, linux | Tags: , , , , , , , | No Comments »

I mentioned previously that I’d been looking at Amazon EC2 as a solution to host a site that underwent heavy bursts of traffic for only a couple of hours a week. The expected traffic bursts were 10-15k visitors in a 2 hour period and unfortunately a small EC2 instance just wasn’t enough. The next trial was with a large EC2 instance, with Apache tweaked to allow more simultaneous connections. Results went better than first time but I ended up having to bounce Apache a couple of times during the time frame to get it back up and running.

So fast forward to this week and it was time to try again. This time I went with an Extra Large instance running a stock 64-bit Ubuntu 8.04 and Lighttpd instead of Apache. And this time there were no problems. For the full 2 hours the site remained up and responsive, and because I could time the instance to come up just before the additional cost was negligible.

To give you an idea of the kind of traffic it had to deal with, the site took in just over 25,000 unique visitors in a 2 hour time frame. Glad to get the problem solved and now I know what to do next time I need some heavy traffic handled.


Installing Ruby on Rails via Passenger on Ubuntu 8.04

Posted: February 19th, 2009 | Author: James | Filed under: Web Development | Tags: , , , , , | 1 Comment »

As part of my postings which focus on ‘Things I’ve Had to Do Recently So Am Writing Them Down So I Don’t Forget’ i’m writing up what I had to do to get Ruby on Rails up and running on my Ubuntu 8.04 development machine.  As before, I’d expect this to run fine on the latest Ubuntu release (8.10 at time of writing).

Installing Apache

Apache installation is nice and easy under Ubuntu and I’m really only including the instructions for the sake of completeness. 

sudo apt-get install apache2

Installing Ruby

Again installing Ruby itself is one of the simple things to get done.

sudo apt-get install ruby-full build-essential

Installing Rails

The best way to install Rails is via Ruby Gems, this allows Gems to be in control of updating Rails (and other Ruby related downloads) and prevents Apt from conflicting with your Gems package.

The latest version of Gems is 1.3.1 which can be installed with the following set of commands.

wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar xzvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
sudo ruby setup.rb
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo gem update --system

With Gems now installed its safe to install Rails.

sudo gem install rails

Installing Passenger

Now that Ruby, Rails and Apache are installed the final step is the installation of Phusion Passenger (or mod_rails as it’s also sometimes referred to).   Passenger can be installed through ruby gems which makes it easier to stay up to date with the latest release.

sudo gem install passenger
sudo passenger-install-apache2-module

Then add the following lines to your httpd.conf

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /usr/bin/ruby1.8

You should now be able to set up a rails app and get it running by pointing an Apache VHost at the directory.

I’d also recommend setting Rails to development mode by adding 

RailsEnv development

to your vhost’s config so you can see any errors generated by Rails in the case that something has gone wrong.


Installing Railo 3 on Tomcat 6 via Apache 2 on Ubuntu 8.04

Posted: January 22nd, 2009 | Author: James | Filed under: Web Development | Tags: , , , , , , , | 20 Comments »

Well that headline is a bit of a mouthful, but i figured if this was something I was attempting to do then there was a good chance that others were attempting the same thing – and what I really could have done with is a guide. So here’s that guide.

First of all I started with a default install of Ubuntu Server 8.04, the latest LTS release. There’s no reason why this shouldn’t work on 8.10 though.

Setting Up Tomcat 6

First things first, install Java.

sudo apt-get install sun-java6-jdk

That should all without a hitch and the next step is to get Tomcat installed. The version available through is apt is version 5.5 and I wanted to use the latest release so after logging in to the server download the latest (6.0.18 at this time) by executing

wget http://apache.hoxt.com/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz
tar xvzf apache-tomcat-6.0.18.tar.gz

Next we need to move Tomcat somewhere permanent.

sudo mv apache-tomcat-6.0.18 /usr/local/tomcat

The next thing to do is set Tomcat to automatically start when the server starts (plus the script makes it easier to start and stop Tomcat). Start up your editor of choice.

sudo nano /etc/init.d/tomcat

And paste in the following script (which I got originally from HowToGeek.com)

# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

export JAVA_HOME=/usr/lib/jvm/java-6-sun

case $1 in
start)
        sh /usr/local/tomcat/bin/startup.sh
        ;; 
stop)   
        sh /usr/local/tomcat/bin/shutdown.sh
        ;; 
restart)
        sh /usr/local/tomcat/bin/shutdown.sh
        sh /usr/local/tomcat/bin/startup.sh
        ;; 
esac    
exit 0

The script also need to be made executable and hooked up to the startup folders.

sudo chmod 755 /etc/init.d/tomcat
sudo nano /etc/init.d/tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

Tomcat should now be up and running!

Railo

To install Railo we first need to get the Railo custom version and copy all of the files into the Tomcat lib directory.

wget http://www.railo-technologies.com/railo/remote/download/3.0.1.000/custom/all/railo-3.0.1.000-jars.tar.gz
tar zxvf railo-3.0.1.000-jars.tar.gz
sudo mv railo-3.0.1.000-jars/* /usr/local/tomcat/lib

The next step is to get Railo and Tomcat working together.  I’ve assumed that you’re only using Tomcat for CFML processing so these instructions only cover installing Railo on a server wide basis rather than being site specific.

Open up the web config file

sudo nano /usr/local/tomcat/conf/web.xml

and append the following inside the <web-app> element.

<servlet>
<servlet-name>CFMLServlet</servlet-name>
<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-mapping>
   <servlet-name>CFMLServlet</servlet-name>
   <url-pattern>*.cfm</url-pattern>
</servlet-mapping>
<servlet-mapping>
   <servlet-name>CFMLServlet</servlet-name>
   <url-pattern>*.cfml</url-pattern>
</servlet-mapping>
<servlet-mapping>
   <servlet-name>CFMLServlet</servlet-name>
   <url-pattern>*.cfc</url-pattern>
</servlet-mapping>

Inside the <welcome-file-list> element insert the following

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

This tells Tomcat what files to process and what to do with them.

Apache

Next we need Apache.  Originally I had installed this by selecting the LAMP stack while installing Ubuntu but if you missed that step then go for

sudo apt-get install apache2

Connecting Apache and Tomcat

There are various ways to connect Apache and Tomcat, but we’ll be using mod_jk which you can install on Ubuntu by typing in 

sudo apt-get install libapache2-mod-jk

To specify the connection between Apache and Tomcat we set up a file called workers.properties and list the different connectors.  Create the file in the Apache directory

sudo nano /etc/apache2/workers.properties

and paste in the following

worker.list=default

worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

We then tell apache where this file is by adding the following to your /etc/apache2/httpd.conf

# Mod_jk settings
JkWorkersFile workers.properties
DirectoryIndex index.html index.htm index.cfm index.cfml

Setting Up A Site

To use Railo on a website we need to configure it in both Apache and Tomcat.  In Tomcat’s server.xml (/usr/local/tomcat/conf/server.xml if you’re following my instructions) add the following (you can add many of these if you need to set it up for each application)

<Host name="your.url.com" appBase="/var/www/vhosts/yoursite">
    <Context path="" docBase=""/>
</Host>

Finally we add the following to your site’s apache vhost config (most likely in /etc/apache2/sites-available)

JkMount /*.cfm default

This tells mod_jk to use the default connector (as specified in the workers.properties file) whenever it encounters a file ending in .cfm.  By setting it up this way we can still use apache to server static files like images, css and js (or even run another language like php side by side with ColdFusion)

Last thing to do is to drop some Coldfusion into your website and check that everything is working.