Knowledge Base

An archive of my personal knowledge base.

Install Maven Repository on Linux Debian (Sonatype Nexus)

Cristian Sulea

When installing Nexus Repository Manager you should configure it to run as a service, so it starts back up after server reboots. It is good practice to run that service or daemon as a specific user that has only the required access righs.

Create a nexus user with sufficient access rights to run the service:

adduser nexus

Download:

wget www.sonatype.org/downloads/nexus-latest-bundle.tar.gz
tar -zxvf nexus-latest-bundle.tar.gz
ln -s nexus-x.x.x-xx nexus

Copy $NEXUS_HOME/bin/nexus to /etc/init.d/nexus and make it executable:

cp /home/nexus/nexus/bin/nexus /etc/init.d/nexus
chmod 755 /etc/init.d/nexus

Edit the script (nano /etc/init.d/nexus) and change the following variables:

NEXUS_HOME="/home/nexus/nexus"
RUN_AS_USER=nexus
PIDDIR="/home/nexus"

Set up the repository manager as a service:

cd /etc/init.d
update-rc.d nexus defaults
service nexus start

Everything Put Together

adduser nexus

wget www.sonatype.org/downloads/nexus-latest-bundle.tar.gz
tar -zxvf nexus-latest-bundle.tar.gz
ln -s nexus-x.x.x-xx nexus

cp /home/nexus/nexus/bin/nexus /etc/init.d/nexus
chmod 755 /etc/init.d/nexus

nano /etc/init.d/nexus
> NEXUS_HOME="/home/nexus/nexus"
> RUN_AS_USER=nexus
> PIDDIR="/home/nexus"

cd /etc/init.d
update-rc.d nexus defaults
service nexus start

Resources

Share on Twitter