Install Nexus Repository Manager on Ubuntu
This guide explains how to install Nexus Repository Manager on Ubuntu. Nexus acts as a central hub to store and manage your application files and software packages. It helps teams share code and tools easily across different servers.
Why use Nexus? It simplifies managing packages for languages like Java, npm, NuGet, and Python. It keeps your files organized and ready for deployment.
What happens when done? You will have a running repository manager accessible through your web browser, allowing you to host and distribute your own software components.
Install Java
Nexus requires a modern version of Java to run. For 2026, you should use OpenJDK 17 or 21, as these are the long-term support versions required by current Nexus releases.
Run these commands to update your system and install OpenJDK 21:
sudo apt update sudo apt install openjdk-21-jdk
You can find more details on managing Java versions at How to install and use OpenJDK on Ubuntu Linux.
Install Nexus Repository Manager
Now, let’s download the latest stable version of Nexus. We will move the files to the /opt directory to keep things organized.
Run these commands to download and extract the files:
cd /tmp wget https://download.sonatype.com/nexus/3/nexus-3.77.0-02-unix.tar.gz tar xzf nexus-3.77.0-02-unix.tar.gz sudo mv nexus-3.77.0-02 /opt/nexus sudo mv sonatype-work /opt/
Next, we create a dedicated user account to run Nexus safely. This account will not be used to log in to the system.
sudo useradd -m -d /opt/nexus -U -r -s /bin/bash nexus sudo chown -R nexus:nexus /opt/nexus /opt/sonatype-work
Configure Nexus to run on Ubuntu
We need to tell Nexus to run as the new user and start automatically when your server boots.
Edit the configuration file to set the user:
sudo nano /opt/nexus/bin/nexus.rc
Uncomment the line and set it to: run_as_user="nexus".
For custom settings like memory limits, use the nexus.vmoptions file or the dedicated configuration directory instead of changing default files.
Now, create a system service file to manage the application:
sudo nano /etc/systemd/system/nexus.service
Paste these lines into the file:
[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
Start the service with these commands:
sudo systemctl daemon-reload sudo systemctl start nexus.service sudo systemctl enable nexus.service
To access the web interface, open your browser and go to http://your-server-ip:8081. 
To log in for the first time, you need the initial admin password. Retrieve it by running:
sudo cat /opt/sonatype-work/nexus3/admin.password
Enter this password in the browser. You will be prompted to create a new, secure password. 
Run Nexus behind a proxy
For better security and performance, it is best to run Nexus behind a web server like Nginx or Apache. See these guides for help:
How to set up a reverse proxy with Nginx
How to set up a reverse proxy with Apache
For more official documentation, visit https://help.sonatype.com/docs.
[Unit] [Service] [Install]
Was this guide helpful?
Leave a Reply