环境:
centos6.8
jdk 1.7
maven 3.3.9
一.下载软件
wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.4-03-bundle.tar.gz
tar -xzvf nexus-2.14.4-03-bundle.tar.gz
二.修改配置
/opt/software/nexus-2.14.4-03/conf/nexus.properties
默认端口是8081,修改成其他端口。
/opt/software/nexus-2.14.4-03/bin/nexus
设置运行用户为root,修改参数为 RUN_AS_USER=root
三.设置环境变量和开机启动
1.修改/etc/profile
JAVA_HOME=/opt/software/jdk
JRE_HOME=$JAVA_HOME/jre
NEZUA_HOME=/opt/software/nexus-2.14.4-03/
PATH=$PATH:$JAVA_HOME/bin:$NEZUA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export JRE_HOME
export PATH
export CLASSPATH
source /etc/profile
2.设置开机启动
cp /opt/software/nexus-2.14.4-03/bin/nexus /etc/init.d/
chkconfig nexus on
chkconfig --list |grep nexus
四.启动nexus,配置私有仓库
nexus start
访问:http://ip:port/nexus
账号:admin
密码:admin123
查看仓库
1.配置远程仓库
开启下载远程仓库的索引。
手动更新索引
cd /opt/software/sonatype-work/nexus/indexer/central-ctx/
rm -rf ./*
wget http://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz
wget http://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.properties
wget https://repo1.maven.org/maven2/org/apache/maven/indexer/indexer-cli/5.1.1/indexer-cli-5.1.1.jar
java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d ./
rm -rf indexer-cli-5.1.0.jar nexus-maven-repository-index.gz nexus-maven-repository-index.properties
nexus restart
查看索引
密码:deployment123
五.配置maven
/opt/software/maven/conf/settings.xml
<profiles>
<profile>
<id>development</id>
<repositories>
<repository>
<id>central</id>
<url>http://192.168.1.6:10001/nexus/content/repositories/central/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://192.168.1.6:10001/nexus/content/repositories/central/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>development</activeProfile>
</activeProfiles>
mvn help:system 查看配置是否正确
六.其他
七.参考
http://www.jianshu.com/p/21675186d8e2
http://www.2cto.com/kf/201606/517491.html