This is a quick run through of installing Apache Archiva 1.3.  I am using Amazon’s EC2 service to host the Ubuntu server, which is running Ubuntu 12.04.2 LTS 64-bit.  The tutorial assumes that you just booted up a new instance, so we will first install open JDK, and will then download and configure Apache Archiva.

Install JDK

Install the Open JDK if you do not have a Java SDK already installed:
1
$ sudo apt-get install openjdk-7-jdk
Confirm the installation and then ensure that java is installed using this command:
1
$ java -version
You should get output similar to:
1
2
3
java version "1.7.0_21"
OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-0ubuntu0.12.04.1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Download and setup separate configuration of Archiva

Download the latest stable version of Apache Archiva using wget from one of their mirrors, and then extract it out and mv it to the /opt directory.  I also created a symlink at /opt/archiva so that my configuration is not version dependent:
1
2
3
4
5
6
$ sudo wget http://mirror.cogentco.com/pub/apache/archiva/1.3.6/binaries/apache-archiva-1.3.6-bin.tar.gz
$ sudo tar -zxvf apache-archiva-1.3.6-bin.tar.gz
$ sudo mv apache-archiva-1.3.6 /opt
$ sudo rm apache-archiva-1.3.6-bin.tar.gz
$ cd /opt
$ sudo ln -s apache-archiva-1.3.6/ archiva
I also chose to separate the base from the configuration of archiva itself, which is recommended in the installation documentation.  To do this, you simply need to create the directories outside of the install root in /opt.  I followed the recommendation and chose to put this in /var/archiva:
1
2
3
4
5
$ sudo mkdir /var/archiva
$ sudo mkdir /var/archiva/conf
$ sudo mkdir /var/archiva/data
$ sudo mkdir /var/archiva/logs
$ sudo cp /opt/archiva/conf/* /var/archiva/conf/

Start Archiva upon system start

I want to have Archiva start when the system starts, so I created an upstart file:
1
$ sudo nano /etc/init/archiva.conf
The upstart configuration file contents set the ARCHIVA_BASE environment variable and start Archiva:
1
2
3
4
5
6
7
8
9
10
11
description "start and stop Apache Archiva"
version "1.0"
 
env ARCHIVA_BASE=/var/archiva
 
start on started networking
stop on shutdown
 
expect fork
 
exec /opt/archiva/bin/archiva start &
I also set the ARCHIVA_BASE environment variable for my current session so I could start up archiva myself:
1
$ export ARCHIVA_BASE="/var/archiva"

Remove 32-bit wrapper

When I tried to start Archiva, I received an error indicating that the wrapper file could not be found:
1
2
3
$ ./archiva start
Starting Apache Archiva...
./archiva: 1: eval: /opt/apache-archiva-1.3.6/bin/./wrapper-linux-x86-32: not found
I opened up the /opt/archiva/bin/archiva script to see what was wrong.  I am not sure if my solution is the best thing, but I added a new variable named ARCHIVA_BIN and used that when setting the WRAPPER_CMD variable:
1
2
3
4
ARCHIVA_BIN="/opt/archiva/bin"
 
# Wrapper
WRAPPER_CMD="$ARCHIVA_BIN/wrapper"
Since I am running a 64-bit instance, I was getting an error indicating that the 32-bit wrapper could not be found:
1
2
3
$ sudo ./archiva start
Starting Apache Archiva...
./archiva: 1: eval: /opt/apache-archiva-1.3.6/bin/wrapper-linux-x86-32: not found
After some light searching, it turns out that most people recommend that you simply remove two files.  I decided to move them to my user’s home directory, just in case I need them later
1
2
sudo mv bin/wrapper-linux-x86-32 ~
$ sudo mv lib/libwrapper-linux-x86-32.so ~

Bind Jetty to port 80

Lastly, I updated the Jetty port to use port 80.  To do this, I edited the /opt/archiva/conf/jetty.xml file, updating the following line:
1
<Set name="port"><SystemProperty name="jetty.port" default="80"/></Set>
I then started up the Archiva server and was able to browse to the URL in my browser