How to Install Nexus Repository Manager on Ubuntu Linux

Share

This article describes steps one can take to install and use Nexus Repository Manager on Ubuntu Linux.

Nexus provides a centralized location to store and manage your application binaries and build artifacts that can be scaled efficiently across multiple servers.

If you are looking for a package repository to support ecosystems such as Java/Maven, npm, NuGet, PyPI, RubyGems, and many others, you will find Nexus to be helpful.

Below are steps that show you how to install and use Nexus repository management on Ubuntu Linux.

How to install and use Nexus repository manager on Ubuntu Linux

As described above, Nexus provides a centralized location to store and manage your application binaries and build artifacts that can be scaled efficiently across multiple servers.

Below is how to install it on Ubuntu Linux.

Before installing Nexus, you should be aware that there are two versions available. One is open-source and the other is commercial, which means you pay for it.

We are going to be installing the open-source version in this post.

Install Java

Nexus repository manager requires Java OpenJDK and JRE v8 and up. The OpenJDK version 8 works great with Nexus, so we’re going to install that version.

Run the commands below to update Ubuntu package indexes and install OpenJDK version 8.

sudo apt update
sudo apt install openjdk-8-jdk

Additional resources on installing and using OpenJDK on Ubuntu can be found at the link below.

How to install and use OpenJDK on Ubuntu Linux

Install Nexus repository manager

Now that OpenJDK is installed, let’s go and download the Nexus package and install it. At the time of this writing, the latest version of Nexus is v3.41.1.

Run the commands below to download the Nexus package.

cd /tmp
wget https://download.sonatype.com/nexus/3/nexus-3.41.1-01-unix.tar.gz

Once the package is downloaded, run the commands below to extract the downloaded file, and move both the nexus and sonatype-work folders to a new nexus folder in the /opt/nexus directory.

tar xzf nexus-3.41.1-01-unix.tar.gz
sudo mv nexus-3.41.1-01 /opt/nexus
sudo mv sonatype-work /opt/

For this post, we are doing to create a dedicated user account called nexus. This account will not be used to log on to the system.

sudo useradd -m -d /opt/nuxus -U -r -s /bin/bash nexus

Once the account is created, change the ownership of the /opt/nexus directory to the nexus user by running the commands below.

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

Configure Nexus to run on Ubuntu

For nexus to function we will have to edit its configuration file and have the service run as the nexus user created above.

Run the commands below to open the /opt/nexus/bin/nexus.rc configuration file.

sudo nano /opt/nexus/bin/nexus.rc

Uncomment the line below to make sure that the service runs as the nexus user.

run_as_user="nexus"

Next, run the commands below to open the nexus properties config file.

sudo nano /opt/nexus/etc/nexus-default.properties

Then make sure to define the application host. By default, Nexus will communicate on all IPs. If you want to use a specific IP address, then define it in the nexus-default.properties file.

application-host=192.168.1.1

Save the file and exit.

Once you are done, run the commands below to create a Nexus systemd service file.

sudo nano /etc/systemd/system/nexus.service

Copy and lines below into the file and save it.

[Unit]
Description=nexus service
After=network.target

[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
User=nexus
Restart=on-abort

[Install]
WantedBy=multi-user.target

Reload systemd-daemon and start Nexus services.

sudo systemctl daemon-reload
sudo systemctl start nexus.service
sudo systemctl enable nexus.service

Nexus should be started and running.

By default, Nexus will use port number 8080 on the local server.

Open your web browser and browse to the server hostname or IP address followed by port number 8081.

http://localhost:8081

Nexus default portal should appear. You can use the default username and password found in the file below to log on.

sudo nano /opt/sonatype-work/nexus3/admin.password
ubuntu install nexus repository manager web portal
ubuntu install nexus repository manager web portal

You will be prompted to change the temporary password when you first log on.

ubuntu nexus repository manager admin dashboard
ubuntu nexus repository manager admin dashboard

Run Nexus behind a proxy

The most efficient way to run Nexus is to run it behind a reverse proxy server. Below are two posts that showed you how to set up a reverse proxy with Nginx and Apache.

That should do it!

More documentation can be found at the link below.

https://help.sonatype.com/docs

Conclusion:

This post showed you how to install and use Nexus repository manager on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.