Redhat7 install sonartype nexus

This article will show you how to install nexus on redhat 7

Prerequisites

  • JDK 1.8 (this article will use open jdk

Install JDK

# Install JDK 1.8
sudo yum install java-1.8.0-openjdk

# Verify installed java 
java -version
# Example output
openjdk version "1.8.0_322"
OpenJDK Runtime Environment (build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)

Download & install sonartype nexus

# Choose a folder to install nexus eg. /usr/share/applications
cd /usr/share/applications
# Download latest nexus package from official site:
sudo wget -O nexus.tar.gz https://download.sonatype.com/nexus/3/nexus-3.37.3-02-unix.tar.gz
# Unpackage gz file
sudo tar -xvf nexus.tar.gz
# Rename nexus 3 folder to nexus
sudo mv nexus-3* nexus
# Create user to run sonartype nexus
sudo adduser nexus
# Change nexus, sonartype-work folder ownership to nexus
sudo chown -R nexus:nexus nexus
sudo chown -R nexus:nexus sonatype-work

Configure and run nexus as a linux service

# Open /nexus/bin/nexus.rc file, update configuration
sudo vi nexus/bin/nexus.rc
# Update to below configuration
run_as_user="nexus"

# Create a system service file for nexus
sudo vi /etc/systemd/system/nexus.service
# Add below change
[Unit]
Description=nexus service
After=network.target

[Service]
Type=forking
LimitNOFILE=65536
User=nexus
Group=nexus
ExecStart=/usr/share/applications/nexus/bin/nexus start
ExecStop=/usr/share/applications/nexus/bin/nexus stop
User=nexus
Restart=on-abort

[Install]
WantedBy=multi-user.target

# Reload system deamon 
sudo systemctl daemon-reload

# Start nexus 
sudo systemctl start nexus

# Verify nexus status
sudo systemctl status nexus.service

# Enable nexus service on machine start
sudo systemctl enable nexus.service    

# Update firewall configuration
sudo firewall-cmd --permanent --add-port=8081/tcp                               

# Reload firewall
sudo firewall-cmd --reload

Go to your server:8081 to access nexus, follow instructions to setup admin user password, now you can start using nexus.

Leave a Comment