# How To Install Nexus on Ubuntu 24.04

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767369390009/33382887-3ac1-46e3-a34d-54b30c4af6ec.png align="center")

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 `sudo` privileges.
    
* **Memory:**
    
    > [**Memory Requirement:**](https://help.sonatype.com/en/sonatype-nexus-repository-system-requirements.html#memory-requirements) 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:

```bash
$ sudo apt update
$ sudo apt install openjdk-21-jdk -y
```

```bash
$ 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:

```bash
$ 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:

```bash
:/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

```bash
$ 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:

```bash
$ 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)

```bash
$ 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:

```bash
$ sudo mv nexus-3.87.1-01 nexus
```

Clean up the tarball to save space:

```bash
$ 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):

```bash
$ sudo adduser nexus
```

Next, add the new `nexus` user to the **sudo** group to grant it root privileges:

```bash
$ sudo usermod -aG sudo nexus
```

Finally, change the ownership of the Nexus installation and data directories to this new user:

```bash
$ 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.

```bash
$ sudo vi /etc/systemd/system/nexus.service
```

Paste the following configuration:

```ini
[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:

```bash
$ vi /opt/nexus/bin/nexus
```

Uncomment the `run_as_user` line and set it to `nexus`:

```bash
run_as_user="nexus"
```

#### Step 5 — Starting the Service

Reload the systemd daemon to recognize the new service:

```bash
$ sudo systemctl daemon-reload
```

Start and enable Nexus:

```bash
$ 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:

```bash
$ tail -f /opt/sonatype-work/nexus3/log/nexus.log
```

Wait until you see the message **"Started Sonatype Nexus** COMMUNITY**"**.

```bash
-------------------------------------------------

Started Sonatype Nexus COMMUNITY 3.87.1-01 (687ac44a)

-------------------------------------------------
```

Then, open your web browser and visit: [`http://your_server_ip:8081`](http://your_server_ip:8081)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767368577118/23312f6d-289a-4b2b-99ca-d012181ab6f6.png align="center")

To retrieve the initial admin password:

```bash
$ 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:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767368788636/23b280ff-99b8-45f8-a8a9-b38b4b9a5871.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767368835454/f81af636-e375-4e86-b461-b13eff36020d.png align="center")

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.
    
* ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767369020445/36fed63a-2f16-4720-892a-751723f51df6.png align="center")
    

* 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.
