Nexus Repository Manager is a powerful tool for managing artifacts and dependencies in your development environment. It supports various formats, including Maven, npm, Docker, and more. This guide will walk you through the steps to set up Nexus on Ubuntu 22.04 LTS.
Prerequisites
Before you begin, ensure you have the following:
A server running Ubuntu 22.04 LTS
A user with sudo privileges
Java 8 or higher installed on your system
At least 4 GB of RAM
Step 1: Install Java
Nexus requires Java to run. Install OpenJDK 8, which is available in the Ubuntu repositories:
sudo apt update -y
sudo apt install openjdk-8-jdk -y
Verify the installation by checking the Java version:
java -version
You should see output indicating that Java 8 is installed.
Step 2: Download Nexus
Navigate to the Sonatype download page and copy the download link for the latest version of Nexus Repository Manager OSS. Use wget
to download it to your server:
cd /opt
sudo wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
Extract the downloaded archive:
sudo tar -xvf latest-unix.tar.gz
sudo mv nexus-3.* nexus
sudo rm latest-unix.tar.gz
Step 3: Configure Nexus
Create a dedicated user for running Nexus:
sudo useradd nexus
Change the ownership of the Nexus files to the nexus user:
sudo chown -R nexus:nexus /opt/nexus
sudo chown -R nexus:nexus /opt/sonatype-work
Edit the nexus.rc
file to specify the Nexus user:
sudo vim /opt/nexus/bin/nexus.rc
Add the following line:
run_as_user="nexus"
Save and exit the file.
Step 4: Create a Systemd Service File
Create a service file to manage the Nexus service:
sudo vim /etc/systemd/system/nexus.service
Add the following content to the file:
[Unit]
Description=Nexus Repository Manager
After=network.target
[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
User=nexus
Restart=on-abort
[Install]
WantedBy=multi-user.target
Save and exit the file.
Reload the systemd daemon to apply the changes:
sudo systemctl daemon-reload
Enable and start the Nexus service:
sudo systemctl enable nexus
sudo systemctl start nexus
Check the status of the Nexus service:
sudo systemctl status nexus
Step 5: Configure Firewall
I used a VM on GCP for setting up nexus, so we have to update the Firewall Policies to allow traffic on port 8081
Step 6: Access Nexus Repository Manager
Open a web browser and navigate to http://<your-VM-ip>:8081
. You should see the Nexus Repository Manager interface.
Step 7: Initial Configuration
The default admin credentials are:
Username:
admin
Password: Located in the
/opt/sonatype-work/nexus3/admin.password
file.
Use these credentials to log in for the first time. You will be prompted to change the password.
Conclusion
You have successfully set up Nexus Repository Manager on Ubuntu 22.04 LTS. You can now configure repositories for different package formats and start managing your artifacts efficiently.
Feel free to explore the extensive features Nexus offers, such as proxying remote repositories, managing security settings, and integrating with CI/CD pipelines.
Also feel free to refer the official documentation for the setting nexus service here