Nexus Installation

Install Sonatype Nexus3 On AWS | Steps Verified | DevOpsToday 2021

Assumptions:

  • You already have an AWS EC2 LINUX 2 ( minimum size t2.medium) Instance Up and Running
  • The Security Groups in your instance has the 8081 PORT open
  • You already SSH or PUTTY into your instance

Note:  

Download link from Sonatype nexus: https://help.sonatype.com/repomanager3/download

Download link for the latest LINUX version: https://download.sonatype.com/nexus/3/latest-unix.tar.gz

1 Year Subscription

Step 1: Nexus requires Java to run. The minimum version is Java 8, so let’s install it:

sudo yum -y install java-1.8.0-openjdk

Step 2: Verify that Java was installed successfully:

java -version

Step 3: Change directory to the OPT directory, where we are going to install Nexus

cd /opt

Step 4: Download the latest Nexus 3 build tar file

sudo wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz

Step 5: Unzip the file

sudo tar -xf latest-unix.tar.gz

Note: Copy the Nexus build version extracted by the tar command. 

Step 6: Rename the tar file to make it easier to use, using the latest Nexus build from the last command

sudo mv nexus-X.XX.X-XX nexus3

e.g. sudo mv nexus-3.28.1-01 nexus3

Step 7: Change the Permissions of the Nexus directories, so we can run them with our ec2-user

sudo chown -R ec2-user:ec2-user /opt/nexus3
sudo chown -R ec2-user:ec2-user  /opt/sonatype-work

Step 8: Instruct Nexus to use the ec2-user to run Nexus by updating the nexus.rc file. Add the “ec2-user” and remove the “#” from the file:

sudo vi /opt/nexus3/bin/nexus.rc
run_as_user=”ec2-user”

Step 9:  Now, let’s configure Nexus as a Service. The first step is to create a soft link for the Nexus3 in our /etc/init.d/ directory

sudo ln -s /opt/nexus3/bin/nexus /etc/init.d/nexus

Step 10:  Change directory to the init.d directory so that we can configure chkconfig

cd /etc/init.d

Step 11: Add Nexus to chkconfig

sudo chkconfig --add nexus

Step 12: Enable Nexus to start on reboot

sudo chkconfig nexus on

Step 13: Now we can start the Nexus Server

sudo service nexus start

Step 14: Verify Nexus is running by checking the status:

sudo service nexus status

Step 15: Open your local browser and enter

http://[YOUR-EC2-LINUX2-INSTANCE-IP]:8081/

Step 16: To get the initial password, open or cat your initial admin password file:

Nexus unlock screen
Nexus admin password

cat /opt/sonatype-work/nexus3/admin.password
nexus get initial password



UCSD DevOps CICD

Did this worked for you? If so, kindly asking that you share this post so that others can complete their Nexus installation as well.

Leave a Comment

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

38 − = 37