注:云服务器开发环境如下
(CentOS + JDK1.7 + Mysql + ZooKeeper + Redis + Nginx + maven*库Nexus)
三、linux 下安装Nexus (本文采用手动安装,并非yum安装)
1.下载nexus
Nexus官网下载地址:http://www.sonatype.org/nexus/go/
第1步:使用wget命令下载 wget 想要下载nexus版本的地址
[root@localhost nexus]# wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.12.0-01-bundle.tar.gz
[root@localhost nexus]# mkdir /usr/local/nexus
[root@localhost nexus]# tar -zxvf nexus-2.12.0-01-bundle.tar.gz -C /usr/local/nexus/
[root@localhost nexus]# cd /usr/local/nexus
[root@localhost nexus]# ls
nexus-2.12.0-01 sonatype-work
(一个 nexus 服务,一个私有库目录)
第2步:编辑 Nexus 的 nexus.properties 文件,配置端口和 work 目录信息(保留默认)
[root@localhost nexus]# cd nexus-2.12.0-01
[root@localhost nexus-2.12.0-01]# ls
[root@localhost nexus-2.12.0-01]# cd conf
[root@localhost conf]# vi nexus.properties
1
2
3
4
5
6
7
8
|
# Jetty section
#默认的port是8081
application-port=2
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
|
如图所示:
第3步:编辑 nexus 脚本, 配置 RUN_AS_USER 参数
[root@localhost conf]# vi /usr/local/nexus/nexus-2.12.0-01/bin/nexus
NEXUS_HOME=".."
改为(不修改默认也可以):
NEXUS_HOME="nexus安装目录"
#RUN_AS_USER=
改为:
RUN_AS_USER=root
如图所示:
第4步:启动 nexus [nexus的bin目录下的可以执行文件可以进入bin查看]
[root@localhost conf]# /usr/nexus/nexus-2.12.0-01/bin/nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.
[root@localhost conf]#
浏览器输入地址 http://公网ip地址:28081/nexus
登录,默认用户名 admin 默认密码 admin123
到此,Nexus 已安装完成。
如下图所示:
如果地址栏输入访问不到,请查看阿里云的安全组规则中是否添加的有28081端口的配置。
maven 中配置nexus的地址
1.打开maven的settings.xml文件,在servers节点下添加如下
<server>
<id>release</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshot</id>
<username>admin</username>
<password>admin123</password>
</server>
2、在repositories节点下添加
<repository>
<id>nexus</id>
<name>remote nexus public</name>
<url>http://公网ip:28081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>habit-snapshot</id>
<name>remote habit-snapshot out</name>
<url>http://公网ip:28081/nexus/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>nexus-3rd</id>
<name>remote nexus 3rd</name>
<url>http://公网IP:28081/nexus/content/repositories/thirdparty/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
保存,刷新maven即可。