操作系统:CentOS 6.5 64bit
Sonatype Nexus 版本:nexus-2.14.5-02-bundle
JDK 版本:JDK 1.8
安装JDK
执行 rpm 安装命令:1
[root@localhost ~]
默认的 JDK 安装目录:1
/usr/java/jdk1.8.0_151
配置 JDK 环境变量:1
[root@localhost ~]
添加如下内容:1
2
3
4#set jdk environment
export JAVA_HOME=/usr/java/jdk1.8.0_151
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
启用配置文件:1
[root@localhost ~]
验证 JDK:1
2
3
4[root@localhost ~]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
安装 Sonatype Nexus
准备安装目录:1
2
3[root@localhost ~]
[root@localhost local]
[root@localhost local]
解压 Sonatype Nexus:1
[root@localhost nexus]# tar –zxvf nexus-2.14.5-02-bundle.tar.gz
解压之后将出现两个目录:1
2[root@localhost nexus]# ls
nexus-2.14.5-02 sonatype-work
前者是 nexus 服务目录,后者是私库目录
启动/停止 Sonatype Nexus
Sonatype Nexus 的启动脚本目录位于:1
2[root@localhost bin]
/usr/local/nexus/nexus-2.14.5-02/bin
Sonatype Nexus 默认不推荐使用 root 用户启动:1
2
3
4
5
6
7[root@localhost bin]# ls
jsw nexus nexus.bat
[root@localhost bin]# ./nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.
若想通过 root 用户启动 Sonatype Nexus 需要修改启动脚本 nexus:1
[root@localhost bin]
设置启动脚本中 RUN_AS_USER 内容:1
RUN_AS_USER=root
重新启动 Sonatype Nexus:1
2
3
4
5
6[root@localhost bin]# ./nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.
停止 Sonatype Nexus:1
2
3
4
5
6[root@localhost bin]# ./nexus stop
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Stopping Nexus OSS...
Stopped Nexus OSS.
配置 Sonatype Nexus 开机启动
1 | [root@localhost bin] |
以系统服务方式启动 Sonatype Nexus:1
2
3
4
5
6[root@localhost conf]# service nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.
配置 Sonatype Nexus 防火墙端口
Sonatype Nexus 默认使用 Jetty,其配置文件目录:1
/usr/local/nexus/nexus-2.14.5-02/conf
查看配置文件:1
[root@localhost conf]
1 | # Jetty section |
默认使用 8081 端口。
在防火墙中添加 8081 端口:1
[root@localhost ~]
添加一条规则:1
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT
重启防火墙服务:1
[root@localhost ~]# service iptables restart
访问 Sonatype Nexus
默认的访问地址:1
http://IP:8081/nexus
默认的用户名和密码:1
admin/admin123