How to Install Nexus on Ubuntu
Nexus is a Sonatype Artifactory repository manager [OSS]. It allows you to store, distribute, and retrieve build artifacts whenever it's required.
Install Mandatory Packages
OpenJDK 1.8
sudo apt-get update
sudo apt-get install openjdk-8-jdk
Execute the below commands — navigate to /opt
directory by changing directory:
cd /opt
Download Nexus
http://download.sonatype.com/nexus/3/nexus-3.22.0-02-unix.tar.gz
Extract Nexus
sudo tar -xvf latest-unix.tar.gz
sudo mv latest-unix nexus
Create a user called Nexus
sudo adduser nexus
Give some password may be as admin, but do remember.
Keep entering enter for all other values and press y to confirm the entries.
Give permission to Nexus user
sudo chown -R nexus:nexus /opt/nexus
sudo chown -R nexus:nexus /opt/sonatype-work
sudo vim /opt/nexus/bin/nexus.rc
change: run_as_user=nexus
Modify memory settings
sudo vim /opt/nexus/bin/nexus.vmoptions
Add all the below changes the file with below highlighted entry:
-Xms512m
-Xmx512m
-XX:+UnlockDiagnosticVMOptions
sudo vim /etc/systemd/system/nexus.service
Copy the below content.
[Unit]
Description=nexus service
After=network.target
[Service]
Type=forking
LimitNOFILE=65536
User=nexus
Group=nexus
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
User=nexus
Restart=on-abort
[Install]
WantedBy=multi-user.target
Now Start Nexus
sudo systemctl enable nexus
sudo systemctl start nexus
sudo systemctl status nexus
If it says stopped, review the steps above and you can troubleshoot by looking into Nexus logs by executing below command:
tail -f /opt/sonatype-work/nexus3/log/nexus.log
Once Nexus is successfully installed, you can access it in the browser by
URL: http://public_dns_name:8081