We currently use Nexus to store the Maven artifacts of private libs and modified 3rd party open source libraries for the
Yoyo App's.
It's also handy as a proxy as we can define proxing routes as know where certain projects are hosted, which alows us to speed up dependency resolution in Maven/Gradle Projects.
Hopefully following steps will help you to install Sonatype Nexus OSS on a EC2 instance on AWS.
We currently use a EC2 micro instance, we have found it's more than enough.
Create a new Security Group called Deployment
.
Allow the following inbound services:
22 (SSH) 0.0.0.0/0
80 (HTTP) 0.0.0.0/0
443 (HTTPS) 0.0.0.0/0
4000 0.0.0.0/0
8080 (HTTP*) 0.0.0.0/0
8081 0.0.0.0/0 (Nexus OSS)
Launch a new EC2 instance
- Amazon Machine Image: Amazon Linux AMI – 64 bit
- Instance Type: t1.micro (micro should be plenty unless you have GB's of deps)
- Security Group:
Deployment
Connect
Download KeyPair into your SSH folder (~/.ssh
):
$ ~/.ssh/YOUR_KEY_PAIR.pem.
Then update the access permissions:
chmod 400 ~/.ssh/YOUR_KEY_PAIR.pem
Connect with your favourite SSH tool to your EC2 instance, find the address of your EC2 instance by selecting it in the Management Console (something like ec2-XX-XXX-XXX-XXX.compute-1.amazonaws.com
).
Your cmd will look similar, if using shell/bash/zsh:
ssh -i ~/.ssh/YOUR_KEY_PAIR.pem ubuntu@ec2-XX-XXX-XXX-XXX.compute-1.amazonaws.com
Install Nexus
Once connected, download and unzip Nexus OSS.
cd /usr/local
sudo wget http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz
sudo tar -xvzf nexus-latest-bundle.tar.gz
sudo rm nexus-latest-bundle.tar.gz
Create a virtual link to the actual nexus-VERSION folder (replace nexus-2.5.1-01
with your nexus installed version)
sudo ln -s nexus-2.5.1-01/ nexus
Create NEXUS_HOME
environment variable.
export NEXUS_HOME=/usr/local/nexus
Create nexus user with restricted permissions.
sudo useradd -m nexus
Change ownership of nexus folder to the nexus user and nexus group.
sudo chown -R nexus:nexus /usr/local/nexus-2.5.1-01/
sudo chown -R nexus:nexus /usr/local/sonatype-work
Edit the nexus executable (necessary for the nexus user and to run nexus as a service).
I’m using the nano
editor since it’s already installed on Ubuntu.
sudo nano /usr/local/nexus/bin/nexus
Change the following lines:
NEXUS_HOME="/usr/local/nexus"
#...
RUN_AS_USER="nexus"
#...
PIDDIR="/home/nexus"
CTRL + X then Y, Enter will save the file.
Launch Nexus
Starting Nexus
cd /usr/local/nexus/bin
sudo ./nexus console
If starting fails, make sure you have a vaild JVM installed, e.g. sudo apt-get install openjdk-7-jre
.
Stopping Nexus
cd /usr/local/nexus/bin
sudo ./nexus stop
Start nexus as a service
Copy the nexus starting script to /etc/init.d
:
sudo cp /usr/local/nexus/bin/nexus /etc/init.d/nexus
Make the nexus script executable:
sudo chmod 755 /etc/init.d/nexus
Enable the Nexus Service settings, (You may need to install chkconfig, sudo apt-get install chkconfig
):
cd /etc/init.d
chkconfig --add nexus
sudo chkconfig --level 345 nexus on
If chkconfig --add
fails, link insserv, sudo ln -s /usr/lib/insserv/insserv /sbin/insserv
.
Now you nexus should start automatically at each OS startup.
You can still start/stop nexus as a service manually:
sudo service nexus start|stop
Access Nexus web dashboard
Once nexus is running should be able to connect to the Nexus Dashboard using the EC2 address followed by the 8081 port and /nexus path:
Login into Nexus and change the default credentials.
Login using the default credentials:
username: admin password: admin123
Once you are loggedin change your admin password, OR, create a new admin account and delete the default admin credentials using the Security -> Users screen accessible through the menu on the left.
Ref:https://help.sonatype.com/display/NXRM2/Adding+Repositories+for+Missing+Dependencies