In today's article, I will talk about how to install Nexus repository manager on Ubuntu. Nexus, helps you to to collect, retrieve, manage our artifacts. Let's get started.
Install Java
First, we need to install Java. If you already have Java installed, you can skip this step. You can install Java by running the following command:
1
sudo apt install openjdk-8-jre-headles
You can check the Java version by running the following command:
1
java -version
Now we have finished installing Java. Let’s move on to the next step. In next step, we will download Nexus repository manager.
Download Nexus
Before downloading the Nexus, we need to `cd` in to `opt` directory. You can do that by running the following command:
1
cd /opt
Now we can download Nexus by running the following command:
Now we have downloaded Nexus. Let’s move on to the next step. In next step, we will extract the Nexus.
Extract Nexus
Now we can extract the Nexus by running the following command:
1
sudo tar -xvzf nexus-3.43.0-01-unix.tar.gz
Rename the extracted Nexus setup folder to nexus by running the following command:
1
sudomv /opt/nexus-3.43.0-01 /opt/nexus
Now we have extracted the Nexus. Let’s move on to the next step. In next step, we will create a user and group for Nexus.
Create an user for Nexus
As a better security practice, we don't run nexus service using root user, so lets create new user named `nexus` to run nexus service by running the following command:
1
sudo adduser nexus
Now we have created a user for Nexus. Let’s set no password for nexus user open the visudo file in ubuntu by running the following command:
1
sudo visudo
Add the following line to the end of the file:
1
nexus ALL=(ALL) NOPASSWD: ALL
Now we have set no password for nexus user. Let’s move on to the next step. In next step, we will give pernission for nexus user.
Give permission for nexus user
Now we can give permission for nexus user by running the following command:
1 2 3
sudochown -R nexus:nexus /opt/nexus
sudochown -R nexus:nexus /opt/sonatype-work
To run nexus as service at boot time, open /opt/nexus/bin/nexus.rc file, uncomment it and add nexus user as shown below:
1
sudo vim /opt/nexus/bin/nexus.rc
1
run_as_user="nexus"
Next we nedd to Increase the nexus JVM heap size, open the /opt/nexus/bin/nexus.vmoptions file, you can modify the size as shown below:
Now we have created a service for Nexus. Let’s move on to the next step. In next step, we will access Nexus.
Access Nexus
If you are running UFW firewall on Ubuntu, open the firewall port 8081 using below command
1
sudo ufw allow 8081
Now we can access Nexus by visiting http://<server_IP:8081>:8081 in our browser. You can login to Nexus using the default username and password. The default username is admin and the default password is admin123. You can change the default password by clicking on the Change password link.
Conclusion
In this tutorial, we have learned how to install Nexus repository on Ubuntu. If you have any issue regarding this tutorial, mention your issue in the comment section or reach me through my E-mail.