Configuring Nexus on Linux

Subscribe to my newsletter and never miss my upcoming articles

Nexus Repository is an OpenSource repository which supports various artifact formats, including Docker, Java and npm. With the help of Nexus, pipelines can be published and retrieved and their dependencies can be managed by using central repositories that are accessible from other environments.

Installing Nexus in Linux

Pre-Requisites:

  1. Java installed
  2. Our machine configured with a non-root sudo user.

Installing Java8

1) First update the package indexes using the command,

sudo apt update

2) Install java using the following commands,

sudo apt-get install default-jre
sudo apt-get install default-jdk

In case we have multiple versions of Java installed we can configure them using the command

sudo update-alternatives --config java

Installing Nexus

1) We need to download the Nexus repository in our device which can be downloaded using the following commands

cd /opt 

sudo  wget https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.16.1-02-unix.tar.gz

sudo  tar -zxvf nexus-3.16.1-02-unix.tar.gz

sudo  mv /opt/nexus-3.16.1-02 /opt/nexus

2) It is noot a good practice to run the Nexus services as a root user so we will use create a user named Nexus for the same purpose and will grant it sudo access.

sudo adduser nexus

3) Set the password for the nexus user to be null using the command

sudo echo "nexus   ALL=(ALL)       NOPASSWD: ALL" >> visudo

4) Change the owner and the file settings

sudo chown -R nexus:nexus /opt/nexus  

sudo chown -R nexus:nexus /opt/sonatype-work

5) Add nexus services to run at boot time

sudo echo 'run_as_user="nexus"' > /opt/nexus/bin/nexus.rc 

sudo ln -s /opt/nexus/bin/nexus /etc/init.d/nexus

6) Login as nexus user and start the services

su - nexus  

/etc/init.d/nexus start

The nexus services will be available on 8081 port on our IP

Screenshot from 2020-10-19 09-50-51.png

No Comments Yet