How To Install Latest Sonatype Nexus 3 on Linux

Install Latest Sonatype Nexus 3 on Linux

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

  1. Same issue for me too as posted by Yogendra, as not able to access nexus 3 using port 8081. Please help.

  2. Does it make sense (or even is it possible) to run nexus service as a user other than “nexus” to avoid adding the user “nexus” to sudoers group?

  3. I have created new EC2 instance RedHat7.5 and install nexus 3 as per above steps. I have successfully installed Nexus but unable to open http://172…..:8081/ url

    Also, I have setup apache on same machine.

    Kindly suggest, what i need to do.

  4. sudo ln -s /app/nexus/bin/nexus /etc/init.d/nexus did not work for me with OSS2.x because the nexus script is calling itself when it is run by a different user than specified in RUN_AS.
    I solved it by defining a proper systemd unit file which is better anyway:

    vi /etc/systemd/system/nexus.service

    Description=Nexus Repository Manager OSS 2.x

    ExecStart=/opt/nexus-2.14.5-02/bin/nexus start
    ExecStop=/opt/nexus-2.14.5-02/bin/nexus stop



Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like