Apache Archiva 5 min install

Standard

Apache Archiva is a quick and easy solution to set up your own repository management server. In this example I use CentOS 6.x for my OS.

How To Install / Configure:

Start by downloading the standalone version of Archiva. I suggest placing it in the opt directory for reasons listed.

cd /opt
wget http://mirror.cc.columbia.edu/pub/software/apache/archiva/2.0.1/binaries/apache-archiva-2.0.1-bin.tar.gz
tar -xvf apache-archiva-2.0.1-bin.tar.gz

Now you need to specify the port for Archiva to run on. The default port is 8080 which can cause conflicts if you are using Tomcat which also defaults to 8080. I have changed the port to 8081.

/opt/apache-archiva-2.0.1/conf/jetty.xml

   
      
         
            
         
         
            
         
         30000
         2
         false
         8443
         5000
         5000
      
   

Now at this point Archiva is ready to run. You can start Archiva by the following command.

/opt/apache-archiva-2.0.1/bin/archiva start

Archiva can now be accessed by going to http://localhost:8081/ in your browser. A simple GUI will allow you to setup administrative privileges.

Running as a service script

The above installation is great but begs for better integration with CentOS. On Linux, the bin/archiva script is suitable for linking from the /etc/init.d/ directory. Creating a custom service script in this directory will allow you to start / stop / restart Archiva easily. This directory is used to control services within the OS.

Start by creating the archiva service file

vim /etc/init.d/archiva
chmod 0777 archiva

I have chmod the archiva file so we can execute it as root. Then add the file the script below:

#!/bin/bash
#
# Simple service script for Apache Archiva
# chkconfig: 35 20 80
# description: Archiva 2.0.1

ARCHIVA_PATH=/opt/apache-archiva-2.0.1/bin

case "$1" in
start)
${ARCHIVA_PATH}/archiva start
;;
stop)
${ARCHIVA_PATH}/archiva stop
;;
status)
${ARCHIVA_PATH}/archiva status
;;
restart)
${ARCHIVA_PATH}/archiva restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac

Test the service script above by running the following commands. It should gracefully control the service.

service archiva start
service archiva stop

I don’t like to have to start archiva everytime I restart my server. Add Archiva to the chkconfig so it will automatically start on restart.

chkconfig --add archiva
chkconfig archiva on

Apache Archiva 2.0.1 is now installed on CentOS.

Leave a Reply

Your email address will not be published.