DEV Community

Cover image for How To Configure and Run Nexus OSS on a Remote Server
Tomislav Kraljic
Tomislav Kraljic

Posted on

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>
Enter fullscreen mode Exit fullscreen mode

4) Update the package manager

apt update
Enter fullscreen mode Exit fullscreen mode

5) Change directories into opt

cd /opt
Enter fullscreen mode Exit fullscreen mode

6) Get the Nexus OSS tar file

wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
Enter fullscreen mode Exit fullscreen mode

7) Untar the file

tar -zxvf latest-unix.tar.gz
Enter fullscreen mode Exit fullscreen mode

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

adduser nexus
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

vim nexus-3.28.1-01/bin/nexus.rc
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

13) Start Nexus

/opt/nexus-3.28.1-01/bin/nexus start
Enter fullscreen mode Exit fullscreen mode

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

 <ipv4_address>:<port>
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

2) Create a volume

docker volume create --name nexus-data
Enter fullscreen mode Exit fullscreen mode

3) Run the image in a container

docker run -d -p 8081:8081 --name nexus-data -v nexus-data:/nexus-data sonatype/nexus3
Enter fullscreen mode Exit fullscreen mode

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

<ipv4_address>:<port>
Enter fullscreen mode Exit fullscreen mode

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

Discussion (0)