Skip to content

Installing Nexus Repository Manager on RHEL/CentOS

This guide provides comprehensive instructions for installing Sonatype Nexus Repository Manager 3 on Red Hat Enterprise Linux (RHEL) and CentOS systems.

About Nexus Repository Manager

Nexus Repository Manager is a universal repository that supports all popular package managers and formats. It serves as a central hub for managing software components and dependencies across your development workflow.

Prerequisites

Before starting the installation, ensure your system meets the following requirements:

  • Operating System: RHEL 7/8/9 or CentOS 7/8/9
  • Java: OpenJDK 8 or 11 (Java 8 minimum required)
  • Memory: Minimum 4GB RAM (8GB+ recommended for production)
  • Disk Space: Minimum 10GB (varies based on repository usage)
  • Network: Internet access for downloading packages
  • User Privileges: Root or sudo access

Version Compatibility

This guide focuses on Nexus Repository Manager 3.x (current version 3.85.0 as of October 2025). Nexus 2.x has reached end-of-life and is no longer recommended for new installations.

Installation Steps

Step 1: Update System and Install Dependencies

Update your system packages and install essential tools:

sudo yum update -y
sudo yum install wget curl unzip java-11-openjdk java-11-openjdk-devel -y

Verify Java installation:

java -version

Java Version Management

If you have multiple Java versions installed, use alternatives --config java to select the appropriate version.

Step 2: Create Nexus User

Create a dedicated system user for running Nexus:

sudo useradd --system --no-create-home --shell /bin/false nexus

Security Best Practice

Running Nexus with a dedicated non-root user enhances security by limiting potential attack vectors.

Step 3: Download Nexus Repository Manager

Navigate to the installation directory and download the latest version:

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

Extract the downloaded archive:

sudo tar -xzf latest-unix.tar.gz
sudo rm latest-unix.tar.gz

The extraction creates two directories: - nexus-<version>/ - Contains the Nexus application - sonatype-work/ - Contains data and configuration files

Create a symbolic link for easier version management:

sudo ln -s nexus-3.* nexus

Step 5: Set Ownership and Permissions

Change ownership to the nexus user:

sudo chown -R nexus:nexus /opt/nexus*
sudo chown -R nexus:nexus /opt/sonatype-work

Step 6: Configure Nexus Environment

Edit the Nexus configuration file:

sudo vim /opt/nexus/bin/nexus.rc

Uncomment and set the run-as user:

run_as_user="nexus"

Configuration Location

The main configuration file is located at /opt/sonatype-work/nexus3/etc/nexus.properties for advanced settings.

Step 7: Configure JVM Settings (Optional)

For production environments, adjust JVM settings in /opt/nexus/bin/nexus.vmoptions:

sudo vim /opt/nexus/bin/nexus.vmoptions

Example production settings:

-Xms2g
-Xmx2g
-XX:MaxDirectMemorySize=3g
-XX:+UnlockExperimentalVMOptions
-XX:+UseCGroupMemoryLimitForHeap
-Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs

Memory Configuration

Ensure your system has sufficient memory. The example above requires at least 8GB RAM total.

Step 8: Create Systemd Service

Create a systemd service file for automatic startup:

sudo vim /etc/systemd/system/nexus.service

Add the following configuration:

[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
TimeoutSec=600

[Install]
WantedBy=multi-user.target

Step 9: Enable and Start Nexus Service

Enable and start the Nexus service:

sudo systemctl daemon-reload
sudo systemctl enable nexus
sudo systemctl start nexus

Check service status:

sudo systemctl status nexus

Startup Time

Nexus can take 2-5 minutes to fully start, especially on first launch. Monitor the logs during startup.

Step 10: Configure Firewall

Open the required port (8081 by default):

sudo firewall-cmd --permanent --add-port=8081/tcp
sudo firewall-cmd --reload
sudo iptables -I INPUT -p tcp --dport 8081 -j ACCEPT
sudo service iptables save

Step 11: Access Nexus Web Interface

Open your web browser and navigate to:

http://your-server-ip:8081

First Login

For the initial login, use: - Username: admin - Password: Found in /opt/sonatype-work/nexus3/admin.password

Post-Installation Configuration

Retrieve Initial Admin Password

sudo cat /opt/sonatype-work/nexus3/admin.password

Setup Wizard

After first login, Nexus will guide you through:

  1. Change admin password
  2. Configure anonymous access
  3. Setup repositories

Security Configuration

Always change the default admin password and configure appropriate user permissions for production use.

Service Management

Common service management commands:

# Start Nexus
sudo systemctl start nexus

# Stop Nexus
sudo systemctl stop nexus

# Restart Nexus
sudo systemctl restart nexus

# View service status
sudo systemctl status nexus

# View logs
sudo journalctl -u nexus -f

Troubleshooting

Common Issues

Service won't start:

  • Check Java installation: java -version
  • Verify file ownership: ls -la /opt/nexus*
  • Review logs: sudo journalctl -u nexus -n 50

Web interface not accessible:

  • Confirm service is running: sudo systemctl status nexus
  • Check firewall settings
  • Verify port binding: sudo netstat -tlnp | grep 8081

Performance issues:

  • Review JVM settings in nexus.vmoptions
  • Monitor system resources: htop or top
  • Check disk space: df -h

Log Locations

  • Service logs: journalctl -u nexus
  • Application logs: /opt/sonatype-work/nexus3/log/
  • Configuration: /opt/sonatype-work/nexus3/etc/

Upgrading Nexus

To upgrade to a newer version:

  1. Backup data:

    sudo systemctl stop nexus
    sudo tar -czf nexus-backup-$(date +%Y%m%d).tar.gz /opt/sonatype-work
    

  2. Download new version:

    cd /opt
    sudo wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
    sudo tar -xzf latest-unix.tar.gz
    

  3. Update symbolic link:

    sudo rm nexus
    sudo ln -s nexus-<new-version> nexus
    sudo chown -R nexus:nexus /opt/nexus*
    

  4. Start service:

    sudo systemctl start nexus
    

Backup First

Always backup your Nexus data directory before performing upgrades.

Security Considerations

Basic Hardening

  • Change default ports if needed
  • Enable HTTPS for production environments
  • Configure proper user roles and permissions
  • Regular security updates
  • Monitor access logs

SSL/TLS Configuration

For production deployments, configure HTTPS by:

  1. Obtaining SSL certificates
  2. Configuring reverse proxy (Apache/Nginx)
  3. Updating firewall rules
  4. Redirecting HTTP to HTTPS

Repository Configuration

After installation, configure repositories for your specific needs:

  • Proxy repositories - Mirror external repositories
  • Hosted repositories - Store your artifacts
  • Group repositories - Combine multiple repositories

Performance Tuning

System-Level Optimizations

# Increase file descriptor limits
echo "nexus soft nofile 65536" >> /etc/security/limits.conf
echo "nexus hard nofile 65536" >> /etc/security/limits.conf

# Configure kernel parameters
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
sysctl -p

Database Configuration

For high-load environments, consider: - Migrating from H2 to PostgreSQL - Configuring database connection pooling - Regular database maintenance

Conclusion

You now have a fully functional Nexus Repository Manager installation on RHEL/CentOS. The service will automatically start on system boot and provide a centralized repository for your development artifacts.

For advanced configuration and repository-specific setup, refer to the official Sonatype Nexus Documentation.

Additional Resources