Voiced by Amazon Polly |
Introduction
In this tutorial, we will guide you through installing and configuring the Nexus Repository Manager on Ubuntu 20.04. However, we’ll take a step further by optimizing the storage setup. Rather than utilizing the root volume for Nexus, we’ll demonstrate how to mount an external volume to a specific path, enhancing flexibility and scalability.
Pioneers in Cloud Consulting & Migration Services
- Reduced infrastructural costs
- Accelerated application deployment
Prerequisites
Before diving into the installation, ensure the following prerequisites are met:
- A server running Ubuntu 20.04.
- A root password is configured for the server.
Step-by-Step Guide
To begin, update your system packages to the latest version using the following command:
1 |
apt-get update -y |
Install Java:
As Nexus is based on Java, install Java version 8 on your system:
1 |
apt-get install openjdk-8-jdk -y |
Verify the installed Java version:
1 |
java -version |
Install Nexus:
To create a separate user for Nexus:
1 |
useradd -M -d /opt/nexus -s /bin/bash -r nexus |
Grant the necessary privileges to the Nexus user:
1 |
echo "nexus ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nexus |
Create a directory for Nexus and download the latest version:
1 2 3 4 |
mkdir /opt/nexus wget https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.29.2-02-unix.tar.gz tar xzf nexus-3.29.2-02-unix.tar.gz -C /opt/nexus --strip-components=1 chown -R nexus:nexus /opt/nexus |
Edit the nexus.vmoptions configuration file:
1 |
nano /opt/nexus/bin/nexus.vmoptions |
Set Java max memory size and replace “../sonatype-work” with “./sonatype-work”:
1 2 3 4 5 6 |
-Xms1024m -Xmx1024m -XX:MaxDirectMemorySize=1024m -XX:LogFile=./sonatype-work/nexus3/log/jvm.log -XX:-OmitStackTraceInFastThrow ... |
Save and close the file. Edit the nexus.rc file to define the run-as user:
1 |
nano /opt/nexus/bin/nexus.rc |
Uncomment and change the following line with the Nexus user:
1 |
run_as_user="nexus" |
Save and close the file. Start the Nexus service:
1 |
sudo -u nexus /opt/nexus/bin/nexus start |
Verify Nexus:
1 |
tail -f /opt/nexus/sonatype-work/nexus3/log/nexus.log |
Nexus should be running and listening on port 8081. Stop the Nexus service:
1 |
/opt/nexus/bin/nexus stop |
Create a systemd service file to manage the Nexus service:
1 |
nano /etc/systemd/system/nexus.service |
Add the following lines:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[Unit] Description=nexus service 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 |
Reload the systemd daemon:
1 |
systemctl daemon-reload |
Start and enable the Nexus service:
1 2 |
systemctl start nexus systemctl enable nexus |
Verify the status of the Nexus service:
1 |
systemctl status nexus |
Configure Nginx as a Reverse Proxy for Nexus:
Install Nginx and create a virtual host configuration file:
1 |
apt-get install nginx -y |
nano /etc/nginx/conf.d/nexus.conf
Add the following lines:
1 2 3 4 5 6 7 8 9 10 11 12 |
upstream backend { server 127.0.0.1:8081; } server { listen 80; server_name nexus.example.com; location / { proxy_pass http://backend/; ... } } |
Verify the Nginx configuration:
1 |
nginx -t |
Restart Nginx to apply the changes:
1 |
systemctl restart nginx |
Verify the status of Nginx:
1 |
systemctl status nginx |
Mount External Storage for Nexus:
Now, let’s enhance Nexus storage by mounting an external volume. Assume the external storage device is /dev/sdb. First, partition and format the disk:
1 2 |
fdisk /dev/sdb mkfs.ext4 /dev/sdb1 |
Create a mount point and mount the external volume:
1 2 |
mkdir /mnt/nexus_data mount /dev/sdb1 /mnt/nexus_data |
Update the /etc/fstab file to ensure the volume is mounted on system reboot:
1 |
echo '/dev/sdb1 /mnt/nexus_data ext4 defaults 0 0' >> /etc/fstab |
Update the Nexus data directory to use the mounted volume:
1 |
nano /opt/nexus/bin/nexus.rc |
Change the line related to the Nexus data directory to:
1 |
karaf.data=/mnt/nexus_data/nexus3 |
Save and close the file. Start the Nexus service:
1 |
systemctl start nexus |
Verify Nexus status:
1 |
systemctl status nexus |
Access Nexus Web Interface:
Retrieve the Nexus admin password:
1 |
cat /opt/nexus/sonatype-work/nexus3/admin.password |
Access the Nexus web UI using your browser and the configured URL. Sign in with the admin username and the obtained password. Complete the setup wizard, configure anonymous access, and finish the setup.
Conclusion
Drop a query if you have any questions regarding Nexus Repository Manager and we will get back to you quickly.
Making IT Networks Enterprise-ready – Cloud Management Services
- Accelerated cloud migration
- End-to-end view of the cloud environment
About CloudThat
CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.
FAQs
1. Why is it beneficial to mount external storage for Nexus Repository Manager?
ANS: – Mounting external storage for Nexus provides several benefits. It allows for better scalability, as the external volume can be easily expanded without modifying the root volume. It also facilitates data management, enabling you to separate Nexus data from the system disk, which is especially crucial for systems with limited root volume space. Additionally, using external storage simplifies backups and data migration processes.
2. What steps are involved in securing the Nexus Repository Manager setup with HTTPS when using Nginx as a reverse proxy?
ANS: – Securing Nexus with HTTPS involves configuring Nginx to handle SSL/TLS termination. First, obtain an SSL certificate from a trusted certificate authority. Next, update the Nginx virtual host configuration file (e.g., nexus.conf) to include SSL directives, specifying the path to the certificate and private key. Configure Nginx to listen on port 443, the default port for HTTPS. Finally, restart the Nginx service to apply the changes. This ensures that data exchanged between clients and Nexus is encrypted, enhancing the overall security of the Nexus web interface.

WRITTEN BY Deepak S
Deepak S works as a Research Intern at CloudThat. His expertise lies in AWS's services. Deepak is good at haunting new technologies and automobile enthusiasts.
Comments