Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

How to install nexus in centos 7?

6 Answer(s) Available
Answer # 1 #

Today I wanted to share some simple installation steps on installing Nexus Repository OSS on CentOS 7. Nexus Repository OSS is a free, open source artifact repository with universal format support provided by Sonatype. More information can be found here.

In my case I want to configure a Proxy Repository for Docker Container Images using Nexus Repository OSS. A Proxy Repository can be defined as follows:

I deployed a CentOS 7 Virtual Machine in my lab environment with the following specs:

The System Requirements for Nexus Repository OSS can be found here.

The following tools can be useful for troubleshooting your setup:

This will give you netstat for example.

This allows you to perform telnet commands on the VM.

2. Nexus Repository OSS requires Java 8 Runtime Environment. Check if you have Java installed, if not, make sure to install it:

3. We will be installing Nexus Repository OSS in a specific folder and create another folder for Data & Log files

4. Download the latest version of Nexus Repository OSS:

5. Extract it to our installation directory (/opt/nexus):

6. Create a Service Account called ‘nexus’ to run the Nexus Repository OSS Application under:

7. Set the necessary permissions on the Nexus folders for the nexus Service Account:

8. Configure the Environment Variables:

9. I changed the following options in the $NEXUS_HOME/bin/nexus.vmoptions config file to make sure we are using the correct folders where the nexus Service Account has permissions on:

10. Configure the run_as_user option in the Nexus Repository OSS Configuration file $NEXUS_HOME/bin/nexus.rc :

11. Create a SystemD Service File in /etc/systemd/system/nexus.service

12. (Optionally – if not using a SystemD Service file) You can increase / decrease the Open File limit in this file  /etc/security/limits.conf by adding the following line to it :

See Sonatype Support article here.

13. (Optionally – if using a SystemD Service file like in point 11) You can increase / decrease the Open File limit in this file  /etc/systemd/system/nexus.service by modifying the following line:

See Sonatype Support article here.

14. Enable & Start the Nexus Service:

15. Nexus Repository OSS is running on port 8081, to check if it’s listening on that port run the following command:

16. Now make sure that the firewall allows connections on port 8081:

17. Take your favourite Web Browser and browse to the following URL:

You should be greeted with the Welcome Page:


For a later blogpost I’m thinking to set this up behind an NGINX Proxy and then afterwards make sure my Repository is used. Stay tuned!

Update Feb 2022: It did end up using Avi (NSX-Advanced Load Balancer) for my Reverse proxy requirements. See my blog article here.

Shubh Walsh
Answer # 2 #

Step 2: Download the latest nexus. You can get the latest download links fo for nexus from here.

Step 3: Set User/Permissions and Configurations

Edit /opt/nexus/bin/nexus.vmoptions file

Edit nexus.rc file.

Uncomment run_as_user parameter and add new value.

We need to modify the file.

Change application-host= and port application-host=9081

Configure the open file limit of the nexus user.

Add the below values to the file.

Step 4: Set Nexus as a System Service

Create the Systemd service file in /etc/systemd/system/.

Add the following contents to the unit file.

Manage Nexus Service, Execute the following command to add nexus service to boot.

Monitor the log file.

Check the running service port.

Show default login password.

Create or Edit this ~/.m2/settings.xml file:

Update contents of the file.

Now hit the following command to deploy jar to nexus repository.

Makes sure ~/.m2/setting.xml file copied properly.

Now open pom.xml file and add this upload dependency inside dependencies tag.

Then add this below content inside project tag.

Using CLI, we can download the jar file from nexus repository.

Upload blob file to nexus repository.

tdvbtoq Singha
Answer # 3 #

Sonatype Nexus is a popular repository manager used worldwide for most of the components, binaries, and build artifacts. It comes with support for the Java Virtual Machine (JVM) ecosystem, including Gradle, Ant, Maven, and Ivy.

Compatible with standard tools including Eclipse, IntelliJ, Hudson, Jenkins, Puppet, Chef, Docker, etc., Sonatype Nexus repo can manage dev components through delivery for the binaries containers, assemblies, and finished goods.

In this tutorial, we will provide you a comprehensive guide on setting up Sonatype Nexus Repository OSS version on CentOS 7.

Before starting the tutorial, let’s look at the minimum system requirements for running the Sonatype Nexus Repo.

Begin with setting the Hostname.

Update your CentOS system.

Install Java using the following command:

After installation is complete, check the java version to make sure you are all set to go to the next step of downloading the Repo.

Navigate to the opt directory:

Copy the latest URL of the Repo from the official website and then download it using wget.

Extract the tar file.

You should see two directories, including nexus files and nexus data directory.

Rename the folders.

I. Add a user for a nexus service.

II. Set the ownership for nexus files and nexus data.

III. Change Nexus configuration and set the custom data directory

Edit “nexus.vmoptions”.

Change the data directory.

Save and exit the file.

IV. Change the user for the nexus service account.

Edit “nexus.rc” file.

Uncomment “run_as_user” parameter and add new value.

V. Stop listening for remote connections.

We need to modify the “” file.

Change application-host= to application-host=

VI. Configure the open file limit of the nexus user.

Add the below values to the file.

Save and the exit file.

Create the Systemd service file in “/etc/systemd/system/”.

Add the following to the file.

Reload systemctl.

Enable service on system boot.

Start service.

Monitor the log file.

Check the service port.

Setup epel Repositories.

List the repositories.

Install Nginx.

set nginx on system boot

check the status of Nginx and start service if the service is not running.

Then go to your DNS manager and add A record for your server.

Here we have used AWS route 53 to setup our DNS.

I. Install certbot packages first.

II. Install certificates.

It will ask a few questions and enter email, domain name, and needed inputs as follows.

After installation is done, open nginx.conf.

You can see certbot SSL configuration.

III. Add Proxy pass

Add the following contents to a Location Blocks.

Save and exit the file.

Check nginx syntax:

Restart Nginx:

Now enable https access to a specific public IP. Run the below command.

If you need to open https to public run below command:

Reload the firewall.

Sign in with the default user name as “admin.”  Run below command in the server and get the password.

After the first login, you should see a similar window, as shown below.

Click on next and set up a new password for the admin user.

Again, click on next, and you should see the “Configure Anonymous Access” window. Do not enable Anonymous Access.

Click on the Next button, and you can see the complete setup.

Click on the finish.

That’s all about installing the Sonatype Nexus Repository OSS on your CentOS 7.

Jahzir Evenson
Answer # 4 #

This article guides you to install and configure Sonatype Nexus 3 in a secure way on an ec2 Linux System.

Step 1: Login to your Linux server and update the yum packages. Also install required utilities.

Step 2: Install OpenJDK 1.8

Step 3: Create a directory named app and cd into the directory.

Step 4: Download the latest nexus. You can get the latest download links fo for nexus from here.

Untar the downloaded file.

Rename the untared file to nexus.

Step 5: As a good security practice, it is not advised to run nexus service with root privileges. So create a new user named nexus to run the nexus service.

Change the ownership of nexus files and nexus data directory to nexus user.

Step 6: Open /app/nexus/bin/nexus.rc file

Uncomment run_as_user parameter and set it as following.

Step 7: If you want to change the default nexus data directory, open the nexus properties file and change the data directory parameter to a preferred location as shown below. If you don’t specify anything, by default nexus data directory will be set to /app/sonatype-work/nexus3

An example configuration is shown below.

It is better to have systemd entry to manage nexus using systemctl. Follow the steps given below for adding nexus as a systemd service.

Create a nexus systemd unit file.

Add the following contents to the unit file.

Now we have all the configurations in place to run nexus.

Execute the following command to add nexus service to boot.

To start the Nexus service, use the following command. If you are having trouble starting nexus, please check the troubleshooting section below.

The above command will start the nexus service on port 8081. To access the nexus dashboard, visit http://:8081. You will be able to see the nexus homepage as shown below.

To log in, use the default username and password.

Default username is admin

You can find the default admin password in /app/sonatype-work/nexus3/admin.password file. The path will be shown in the login screen as show below.

Once you login, you will be prompted to reset the password.

For stopping nexus, execute

For restarting nexus,

Sometimes, if the server is enabled with SELINUX, you might get the following error. (Commonly on Centos Servers)

Execute the following command and see the actual error.

Check the output for the following SELINUX issue.

To rectify this issue, add a SELinux policy to allow Systemd to access the nexus binary in path /app/nexus/bin/nexus using the following command.

Boti Annabi
Section Gangs
Answer # 5 #

1.1. Install Prerequisites.

1.2. Install openJDK.

1.3. Install Nexus.

1.4. Configure environment variables.

1.5. Change Nexus default values in $NEXUS_HOME/bin/nexus.vmoptions as follows.

1.6. Configure application-host in $NEXUS_HOME/etc/ as follows in order to stop listening for remote connections.

1.7. Configure nexus service account in $NEXUS_HOME/bin/nexus.rc

1.8. Create SystemD service file in /etc/systemd/system/nexus.service

1.9. Increasing the open file limit of nexus user in /etc/security/limits.conf

1.10. Start and Enable Nexus service

1.11. Check whether the nexus service is running

1.12. Monitoring nexus log files for issues

2.1. Install Nginx.

2.2. Configure SSL.

2.3. Replace the content of /etc/nginx/nginx.conf with the following.

2.4. Create /etc/nginx/conf.d/nexus.conf file as follows.

2.5. SELinux policy to allow Nginx to connect to the network.

2.6. Start and Enable Nginx.

2.7. Open TCP port 80 and 443 through firewall.

Masaya Rutter
Immunology Nursing
Answer # 6 #
  • yum install -y epel-release unzip vim wget.
  • yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel.
  • # Creating necessory folder structure. mkdir -p /data/nexus-data /opt/nexus.
  • # Setting up the default JDK.
  • -Xms1200M.
  • # Listen on localhost only.
  • run_as_user="nexus"
  • [Unit]
Ángela Grunes
Light Board Operator