LINUX Install nexus Private Server and Use

Posted by bqheath on Mon, 20 Jan 2020 20:02:19 +0100

Download and unzip the nexus package

#This download version 2.14.3-02 can be updated to 3.13.0-01
# wget "https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.3-02-bundle.tar.gz"
# tar xfvz nexus-2.14.3-02-bundle.tar.gz

Configuring nexus environment variables

# cd /etc
# vi profile

i Enter edit mode, add environment variable configuration at the bottom of the file

export RUN_AS_USER=root

export JAVA_HOME=/usr/local/software/jdk1.8.0_161 //jdk directory

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=.:$JAVA_HOME/bin:$RUN_AS_USER:$PATH

esc exits edit mode, shift+z+z saves exits

esc exits edit mode, shift+z+z saves exits

Modify Default Port (8081)

# cd /usr/local/software/nexus/nexus-2.14.3-02/conf
# VI nexus.properties //19 line application-port=8081 can be specified instead

Make sure firewalls and server rules open the configured interfaces

Start nexus

# cd /usr/local/software/nexus/nexus-2.14.3-02/bin
# ./nexus start

nexus management interface

Access address: http://ip:port/nexus

Local MAVEN uses private Nexus

Configure setting s file

<?xml version="1.0" encoding="UTF-8"?>     
<settings   xmlns="http://maven.apache.org/POM/4.0.0"    
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  
    <localRepository>G:\singlecase\repository\</localRepository> <!--Local warehouse -->
    <servers>
    <server>
    <id>sc</id>
    <username>admin</username>        <!--Private User Name -->
    <password>admin123</password>
    </server>
    </servers>
     <profiles>
        <profile>
            <id>default</id>
    <repositories>
    <repository>
          <id>sc</id>
          <name>Public Repositories</name>
          <url>http://ip:port/nexus/content/repositories/releases/</url>
      </repository>
    </repositories>
    <pluginRepositories>
      <pluginRepository>
         <id>sc</id>
         <name>Public Repositories</name>
         <url>http://ip:port/nexus/content/repositories/releases/</url>
     </pluginRepository>
 </pluginRepositories>
 </profile>
 </profiles>
 <activeProfiles>
    <activeProfile>default</activeProfile>
  </activeProfiles>
</settings>  

pom file configuration

<distributionManagement>
          <repository>
              <id>lh</id>
             <name>User Project Release</name>
              <url>http://ip:port/repository/maven-releases/</url>
          </repository>
  </distributionManagement>

Upload jar to private service

Quote Private Server jar

<dependency>
            <groupId>xxx</groupId>
            <artifactId>model</artifactId>
            <version>LATEST</version>
    </dependency>

Topics: nexus Maven Apache SSL