搭建Maven私服,并配置Nexus环境
2.安装步骤
2.1 Nexus下载地址:
http://www.sonatype.org/nexus/go (最新版本)
http://www.sonatype.org/nexus/archived_version?id=51 (nexus-2.12.2-bundle.tar.gz)
2.2 将nexus-2.12.2-bundle.tar.gz上传到/tmp目录,并解压出两个目录(nexus-2.12.2-03|sonatype-work),然后移动到安装目录:
[root@localhost tmp]# tar -zxvf nexus-2.12.2-bundle.tar.gz
[root@localhost tmp]# mv nexus-2.12.2-03 /usr/local/nexus
[root@localhost tmp]# mv sonatype-work /usr/local/nexus/nexus-work
2.3 编辑Nexus的nexus.properties文件,配置端口和work目录信息:[root@localhost ~]# vim /usr/local/nexus/conf/nexus.properties
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
# 配置地址
# nexus-webapp-context-path=/nexus
nexus-webapp-context-path=/
# Nexus section
## 配置work目录地址,Maven仓库JAR缓存地址
# nexus-work=${bundleBasedir}/../sonatype-work/nexus
nexus-work=${bundleBasedir}/nexus-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF
2.4 编辑Nexus文件,复制nexus到/etc/init.d/目录,配置NEXUS_HOME/RUN_AS_USER/PIDDIR参数,然后设置为开机启动
[root@localhost ~]# vim /usr/local/nexus/bin/nexus
修改的地方 ~>
# Set this to the root of the Nexus installation.
# NEXUS_HOME=".."
NEXUS_HOME="/usr/local/nexus"
# The user can be changed.
# RUN_AS_USER=
RUN_AS_USER=root
# Location of the pid file. # PIDDIR="."
PIDDIR="/var/run"
# JAVA HOME
JAVA_HOME=/usr/local/jdk7 PATH=$JAVA_HOME/bin:$PATH
[root@localhost ~]# cp /usr/local/nexus/bin/nexus /etc/init.d/
[root@localhost ~]# cd /etc/init.d/
[root@localhost init.d]# chmod 755 nexus
[root@localhost init.d]# chkconfig nexus on
[root@localhost init.d]# service nexus start
3.0安全配置nexus。
3.1 阻止URL直接访问nexus
选择allow file browsing 选择false
访问这个URL http://192.168.10.60:8081/content/repositories/central/会404报错。
知道能通过maven的setting.xml配置密码才能访问。
3.2
参考资料:http://wiki.jikexueyuan.com/project/linux-in-eye-of-java/Nexus-Install-And-Settings.html