How To Install Nexus on Ubuntu 24.04

Sonatype Nexus is a popular repository manager used to store and manage build artifacts. In this guide, you will install Nexus Repository Manager OSS on an Ubuntu 24.04 server.
Prerequisites
Server: Ubuntu 24.04.
User: A non-root user with
sudoprivileges.Memory:
Memory Requirement: Nexus requires a minimum of 4GB RAM, but 8GB RAM is highly recommended for production environments to handle the heap and direct memory requirements efficiently.
Step 1 — Installing Java
Newer versions of Nexus have updated their Java requirements.
Supported Java Versions: "Nexus Repository is tested on and supports OpenJDK and requires Java 21. Nexus Repository is compatible with both Intel and AMD CPU architectures. As of release 2.78.0 the Nexus Repository bundle includes the recommended JVM. See Java Compatibility Matrix."
While the Nexus bundle includes a JVM, installing OpenJDK 21 on your system ensures that all environment variables are correctly set and provides a fallback if you choose to run Nexus with an external JDK.
Update your package index and install OpenJDK 21:
$ sudo apt update
$ sudo apt install openjdk-21-jdk -y
$ java -version
openjdk version "21.0.9" 2025-10-21
OpenJDK Runtime Environment (build 21.0.9+10-Ubuntu-124.04)
OpenJDK 64-Bit Server VM (build 21.0.9+10-Ubuntu-124.04, mixed mode, sharing)
Output should indicate OpenJDK 21.
Step 2 — Downloading Nexus
Navigate to the /opt directory:
$ cd /opt
Download the specific Nexus release (version 3.87.1-01) using curl. The -O flag saves the file with its original name, and -L ensures redirects are followed if necessary:
:/opt$ sudo curl -L -O https://download.sonatype.com/nexus/3/nexus-3.87.1-01-linux-x86_64.tar.gz
Make sure it is downloaded
$ ll
total 457364
drwxr-xr-x 3 root root 4096 Jan 2 15:11 ./
drwxr-xr-x 22 root root 4096 Dec 27 22:19 ../
drwxr-xr-x 4 root root 4096 Dec 27 22:20 digitalocean/
-rw-r--r-- 1 root root 468321562 Jan 2 15:25 nexus-3.87.1-01-linux-x86_64.tar.gz
Extract the archive:
$ sudo tar -xvzf nexus-3.87.1-01-linux-x86_64.tar.gz
Make sure it is extracted (Two directories are extracted: nexus-3.87.1-01 and sonatype-work)
$ ll
total 457372
drwxr-xr-x 5 root root 4096 Jan 2 15:26 ./
drwxr-xr-x 22 root root 4096 Dec 27 22:19 ../
drwxr-xr-x 4 root root 4096 Dec 27 22:20 digitalocean/
drwxr-xr-x 6 root root 4096 Jan 2 15:26 nexus-3.87.1-01/
-rw-r--r-- 1 root root 468321562 Jan 2 15:25 nexus-3.87.1-01-linux-x86_64.tar.gz
drwxr-xr-x 3 root root 4096 Dec 3 21:13 sonatype-work/
Rename the extracted directory to nexus for easier management:
$ sudo mv nexus-3.87.1-01 nexus
Clean up the tarball to save space:
$ sudo rm nexus-3.87.1-01-linux-x86_64.tar.gz
Step 3 — Creating a Dedicated User
Create a new user named nexus. You will be prompted to set a password and fill in user details (you can press ENTER to skip the details):
$ sudo adduser nexus
Next, add the new nexus user to the sudo group to grant it root privileges:
$ sudo usermod -aG sudo nexus
Finally, change the ownership of the Nexus installation and data directories to this new user:
$ sudo chown -R nexus:nexus /opt/nexus
$ sudo chown -R nexus:nexus /opt/sonatype-work
Step 4 — Configuring Nexus as a Service
Create a systemd unit file to manage the Nexus process.
$ sudo vi /etc/systemd/system/nexus.service
Paste the following configuration:
[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
Save and exit the file.
Next, explicitly set the run user in the Nexus run configuration:
$ vi /opt/nexus/bin/nexus
Uncomment the run_as_user line and set it to nexus:
run_as_user="nexus"
Step 5 — Starting the Service
Reload the systemd daemon to recognize the new service:
$ sudo systemctl daemon-reload
Start and enable Nexus:
$ sudo systemctl start nexus
$ sudo systemctl enable nexus
Step 6 — Accessing Nexus
Nexus takes a few minutes to bootstrap. You can watch the logs to see when it is ready:
$ tail -f /opt/sonatype-work/nexus3/log/nexus.log
Wait until you see the message "Started Sonatype Nexus COMMUNITY".
-------------------------------------------------
Started Sonatype Nexus COMMUNITY 3.87.1-01 (687ac44a)
-------------------------------------------------
Then, open your web browser and visit: http://your_server_ip:8081

To retrieve the initial admin password:
$ sudo cat /opt/sonatype-work/nexus3/admin.password
Sign in with the username admin and the password retrieved above. Follow the setup wizard to configure your new installation.
You will be asked to change the admin password as below:

Click “Next” and then “Agree End User License Agreement”

Then, Configure Anonymous Access: The wizard will ask if you want to enable anonymous access. Choose the option that best fits your environment:
Enable anonymous access: Select this if you want to allow anyone with network access to search, browse, and download components without credentials. This is convenient for strictly internal networks or public open-source repositories.
Disable anonymous access: Select this to force all users and build tools (like Maven, Gradle, or Docker) to provide a username and password. This is the secure choice for protecting private or proprietary code.

- Click Next and then Finish to complete the wizard.
Conclusion
You have successfully installed and configured Sonatype Nexus Repository Manager on your Ubuntu 24.04 server. You now have a centralized repository manager running with a dedicated user and configured as a systemd service, ensuring it starts automatically upon server reboot.
With Nexus up and running, your development team can now store, organize, and distribute artifacts efficiently.



