Sonatype Nexus is one of the best repository managers out there. It is some tool that you cannot avoid in your CI/CD pipeline. It effectively manages deployable artifacts.

Sonarqube requirements

  1. Minimum 1 VCPU & 2 GB Memory
  2. Server firewall opened for port 22 & 8081
  3. OpenJDK 8
  4. All Nexus process should run as a non-root nexus user.

Note: For production setup, please consider minimum production hardware requirements based on the nexus usage and data storage. Checkout the official system requirements document for detailed information

Sonatype Nexus 3 on Linux ec2

This article guides you to install and configure Sonatype Nexus 3 in a secure way on an ec2 Linux System.

Note: This was tested on a Redhat machine and it will work on Centos or related Linux flavours as well.

Step 1: Login to your Linux server and update it. Also install required utilities.

sudo yum update -y
sudo yum install wget -y

Step 2: Install OpenJDK 1.8

sudo yum install java-1.8.0-openjdk.x86_64 -y

Step 3: Create a directory named app and cd into the directory.

sudo mkdir /app && cd /app

Step 4: Download the latest nexus. You can get the latest download links fo for nexus from here.

sudo wget -O nexus.tar.gz

Untar the downloaded file.

sudo tar -xvf nexus.tar.gz

Rename the untared file to nexus.

sudo mv nexus-3* nexus

Step 5: As a good security practice, it is not advised to run nexus service with any sudo user. So create a new user named nexus.

sudo adduser nexus

Change the ownership of nexus files and nexus data directory to nexus user.

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

Step 6: Open /app/nexus/bin/nexus.rc file

sudo vi  /app/nexus/bin/nexus.rc

Uncomment run_as_user parameter and set it as following.


Step 7: If you want to change the default nexus data directory, open nexus properties file and change the data directory “” parameter to a preferred location as shown below. If you dont specify anything, by default nexus data directory will be set to /app/sonatype-work/nexus3

Tip: For production setup, it is is always better to mount the nexus data directory to a separate data disk attached to the server. So that backup and restore can be done easily.

sudo vi /app/nexus/bin/nexus.vmoptions

An example configuration is shown below.


Running Nexus as a System Service

It is better to have systemd entry to manage nexus using systemctl. Follow the steps given below for the setup.

Create a nexus systemd unit file.

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

Add the following contents to the unit file.

Description=nexus service

ExecStart=/app/nexus/bin/nexus start
ExecStop=/app/nexus/bin/nexus stop


Manage Nexus Service

Now we have all the configurations in place to run nexus.

Execute the following command to add nexus service to boot.

sudo chkconfig nexus on

To start the Nexus service, use the following command.

sudo systemctl start nexus

The above command will start the nexus service on port 8081. To access the nexus dashboard, visit http://:8081. You will be able to see the nexus homepage as shown below.

nexus 3 homepage

To log in, use the default username and password.

Default username is admin

You can find the default admin password in /app/sonatype-work/nexus3/admin.password file.

cat /app/sonatype-work/nexus3/admin.password

For stopping,

sudo systemctl stop nexus

For restarting,

sudo systemctl restart nexus

You Might Like: How To Setup Latest Nexus OSS On Kubernetes

Install Latest Sonatype Nexus 3 on Linux