How To Configure and Run Nexus OSS on a Remote Server

How To Configure and Run Nexus OSS on a Remote Server

In this tutorial, I will teach you the two ways to configure/run the Nexus Repository Manager on a remote server.

For the remote servers, I will be using Digital Ocean.

Let's get started!

Running Nexus Directly on Server

1) First, we want to create our remote server on Digital Ocean.

2) Configure the Firewall Rules as such:

Firewall Rules

Do not forget to add the droplet to the firewall as well.

3) SSH into your remote server through the terminal.

ssh root@<ipv4_address>

4) Update the package manager

apt update

5) Change directories into opt

cd /opt

6) Get the Nexus OSS tar file

wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz

7) Untar the file

tar -zxvf latest-unix.tar.gz

8) Create a new user because we do not want to run a service as root.

adduser nexus

9) Grant ownership of Nexus folders/files to the new user

chown -R nexus:nexus nexus-3.28.1-01
chown -R nexus:nexus sonatype-work

10) Open nexus.rc and add the new user you created

vim nexus-3.28.1-01/bin/nexus.rc

11) Uncomment and add the user inside the quotes and exit.

12) Switch to new user

su - nexus (or whatever you named the new user)

13) Start Nexus

/opt/nexus-3.28.1-01/bin/nexus start

14) Enter the IPv4 address of the remote server you created and add the port in the URL search bar.

 <ipv4_address>:<port>

Congratulations! You have successfully configured Nexus on your remote server!


Running Nexus Repository Manager via Docker

1) Pull the image from DockerHub

docker pull sonatype/nexus3

2) Create a volume

docker volume create --name nexus-data

3) Run the image in a container

docker run -d -p 8081:8081 --name nexus-data -v nexus-data:/nexus-data sonatype/nexus3

4) Enter the IPv4 address of the remote server you created and add the port in the URL search bar.

<ipv4_address>:<port>

Congratulations! You have successfully started Nexus on your remote server using Docker!