How to Set Up and Run Your Nexus Server: A Step-by-Step Guide

How to Set Up and Run Your Nexus Server: A Step-by-Step Guide

INTRODUCTION

Nexus is a specialized hub for safely storing and managing software components used in building applications. It's like a highly organized warehouse that keeps all the essential parts developers use in one secure place, ensuring reliability and control over dependencies.

Then you may ask what makes Nexus stand out from GitHub is its focus on managing these software components securely. While GitHub is more about collaboration and sharing code among developers, Nexus prioritizes security and control over software components, ensuring stability and reliability within projects.

PREREQUISITES

  • Create an large storage ubuntu server instance on aws and connect to that server using linux terminal .

For that u can refer this blog:

  • Install java 1.8 in that server using command sudo apt update (if required) and sudo apt install openjdk-8-jdk .

check by using java -version.

SETTING UP NEXUS

  • Install nexus package in opt directory

    Using commands:

    cd /opt

    wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz

    check using:

    ls

  • Extract the gzipped archive file

    Using commands:

    tar -zxvf file_name

    check using:

    ls

    # You will see two folder nexus and sonatype .Nexus contain the runtime and application for nexus sonatype contain your own configuration for nexus

  • Create new user to run Nexus

    We are not going to use Root user to run nexus as running such applications as root can expose your system to various security risks. If there are any vulnerabilities in the application, an attacker could potentially gain control over your entire system.

    Create new user using:

    sudo adduser nexus

    Change ownership and grant necessary permissions:

    sudo chown -R nexus:nexus /path/to/nexus sudo chown -R nexus:nexus /path/to/sonatype

    sudo chmod -R 755 /path/to/nexus

    sudo chmod -R 755 /path/to/sonatype

Setting nexus configuration

run command:

sudo nano nexus.../bin/nexus.rc (nexus.... means directory we have in opt )

uncomment the file and set it to nexus

[ run_as_user="nexus" ]

Save and exit the file using ctrl o and ctrl x .

STARTING NEXUS

  • switch to nexus user

    su - nexus

  • Start Nexus:

    /opt/nexus.../bin/nexus start

  • Check Process Status and Port number :

    ps aux | grep nexus

    netstat -lntp | grep java

    Nexus typically runs on port 8081 by default, so you can look for a line indicating the Java process associated with port 8081.

Add port 8081 to your aws instance

  1. Open AWS Console

  2. Go to EC2 Dashboard

  3. Select Security Groups

    From the EC2 Dashboard, click on "Security Groups" in the left-hand menu.

  4. Select Security Group ass

  5. Edit Inbound Rules

  6. Add Port:

    Click Add Rule

    • Protocol: TCP

    • Port Range: 8081

    • Source: (e.g., 0.0.0.0/0 for unrestricted access)

  7. Save Changes:

    Save the changes to the security group.

ACCESSING IT ON YOUR BROWSER

In your browser run :

http://your_aws_public_ip:8081

CONCLUSION

Here it is if you've finished reading this and did everything as mentioned you should be seeing webpage of nexus on your browser just login and upload your precious artifacts.

:ps after done using nexus don't forgot to stop your instance from aws console as we are using paid large instance this time ^_~.

Happy Coding :)

Thank you for being here!! give it a thumbs up, drop a comment and share if you find it even a little helpful.

Did you find this article valuable?

Support Akshat's blogs by becoming a sponsor. Any amount is appreciated!