ayafor-code / Nexus-Installation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nexus-Installation

Pre-requisite:

Create Redhat EC2 t2.medium Instance with 4GB RAM.
Create Security Group and open Required ports.
8081
Attach Security Group to EC2 Instance.
Install java openJDK 1.8+ for Nexus version 3.15
* Create nexus user to manage the Nexus server.
#As a good security practice, it is not advised 
#to run nexus service as a root user.
* so create a new user called nexus and grant sudo access to manage nexus services as follows,
sudo hostnamectl set-hostname nexus
sudo useradd nexus
## Grand sudo access to nexus user
sudo echo "nexus ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/nexus 
sudo su - nexus
## Install Java as a pre-requisit for nexus and other softwares
cd /opt
sudo yum install wget git nano unzip -y
sudo yum install java-11-openjdk-devel java-1.8.0-openjdk-devel -y
## Download nexus software and extract it (unzip).
sudo wget http://download.sonatype.com/nexus/3/nexus-3.15.2-01-unix.tar.gz 
sudo tar -zxvf nexus-3.15.2-01-unix.tar.gz
sudo mv /opt/nexus-3.15.2-01 /opt/nexus
sudo rm -rf nexus-3.15.2-01-unix.tar.gz
## Grant permissions for nexus user to start and manage nexus service
# Change the owner and group permissions to /opt/nexus and /opt/sonatype-work directories.
sudo chown -R nexus:nexus /opt/nexus
sudo chown -R nexus:nexus /opt/sonatype-work
sudo chmod -R 775 /opt/nexus
sudo chmod -R 775 /opt/sonatype-work
vi /opt/nexus/bin/nexus.rc file and uncomment 
run_as_user parameter and set as nexus user.
# change from #run_as_user="" to [ run_as_user="nexus" ]
echo  'run_as_user="nexus" ' > /opt/nexus/bin/nexus.rc

## CONFIGURE NEXUS TO RUN AS A SERVICE:
sudo ln -s /opt/nexus/bin/nexus /etc/init.d/nexus
#9 Enable and start the nexus services
sudo systemctl enable nexus
sudo systemctl start nexus
sudo systemctl status nexus
echo "end of nexus installation"

About