必要环境:Centos,JDK7,Maven,Sonatype Nexus
IP:192.168.25.135 /root 确保JDK已经成功安装并且配置好环境变量
1.下载Sonatype Nexus:
https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.2-03-bundle.tar.gz
2.解压:
- 创建解压文件所需要的目录并解压文件到该目录
# mkdir nexus
# tar -zxvf nexus-2.11.2-03-bundle.tar.gz -C nexus
# cd nexus
# ls (可以看到有两个目录)
nexus-2.11.2-03(存放nexus服务目录) sonatype-work(存放私有库目录)
- 编辑nexus-2.11.2-03的nexus.properties文件
# cd nexus-2.11.2-03/conf
# vi nexus.properties
# Sonatype Nexus
# ==============
# This is the most basic configuration of Nexus.
# Jetty section
# 在这里修改端口,一般不做修改
application-port=**8081**
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF
- 编辑 nexus 脚本, 配置 RUN_AS_USER 参数
#RUN_AS_USER=
改为:
RUN_AS_USER=root - 打开防火墙的8081端口,与上面所修改的一致
# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# 打开8081端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT
- 启动nexus:
进入到nexus的bin目录:cd /root/nexus/nexus-2.11.2-03/bin
启动: ./nexus start
******************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
******************************
Starting Nexus OSS…
Started Nexus OSS. - 访问nexus http://192.168.25.135:8081/nexus
- 此时,一个Maven的私有库就搭建完成了。下一篇将说一下如何通过在IDE中配置和访问私有库