安装Nexus的前提是已经安装JDK,JDK的安装这里就不再赘述,安装JDK-1.7版本,JDK版本过低在启动Nexus的时候会报错.
下载与启动
下载链接为http://www.sonatype.org/nexus/go/ 最新版本为 nexus-2.11.4-01 ,我们下载NEXUS OSS(TGZ). 得到nexus-2.11.4-01-bundle.tar.gz
- 将
nexus-2.11.4-01-bundle.tar.gz复制到/usr/local目录下
sudo cp nexus-2.11.4-01-bundle.tar.gz /usr/local
cd /usr/local
- 解压
nexus-2.11.4-01-bundle.tar.gz,得到nexus-2.11.4-01和sonatype-work两个文件夹,为了以后操作方便,我们将创建软链接nexus指向nexus-2.11.4-01
sudo tar -zxvf nexus-2.11.4-01-bundle.tar.gz
sudo ln -s nexus-2.11.4-01 nexus
- 启动
Nexus
cd nexus
sudo bin/nexus
输出:
Usage: bin/nexus { console | start | stop | restart | status | dump }
根据英文即可知道每个命令的意思,现在启动Nexus
sudo 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.
此时修改bin/nexus文件设置RUN_AS_USER
sudo vim bin/nexus
将 #RUN_AS_USER=
改成 RUN_AS_USER=root
重新启动Nexus
sudo bin/nexus start
输出:
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.
打开localhost:8081/nexus 进行查看,启动成功.如果打不开怎么办? 查看日志
vim logs/wrapper.log
根据错误提示来修改配置文件.
- 修改
nexus的端口
sudo vim conf/nexus.properties
将application-port=8081 改成你想设置的端口,例如9000.
nexus.properties文件中的nexus-work:指定构件库的存储位置
将Nexus设置为系统自启动服务
- 复制
/usr/local/nexus/bin/nexus文件到/etc/init.d/
sudo cp /usr/local/nexus/bin/nexus /etc/init.d/
- 修改
/etc/init.d/nexus
sudo vim /etc/init.d/nexus
添加修改以下变量:
NEXUS_HOME="/usr/local/nexus"
RUN_AS_USER=root
PIDDIR="/var/run"
- 启动
nexus服务
sudo service nexus start #启动
sudo service nexus stop #停止服务
sudo service nexus status #查看服务状态
启动之后,跟之前所述一样,打开http://localhost:8081/nexus即可.
提示
默认登录用户名为admin,密码admin123
使用nginx
nginx是一个非常轻量级的HTTP服务器,nginx,它的发音为“engine X”, 是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理服务器。
-
nginx安装
sudo apt-get install nginx
默认nginx安装,所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下, 启动程序文件在/usr/sbin/nginx,日志放在了/var/log/nginx中,分别是access.log和error.log,并已经在/etc/init.d/下创建了启动脚本nginx,默认的虚拟主机的目录设置在了/usr/share/nginx/www
安装过之后,默认已经启动.查看是否启动:
sudo service nginx status #查看状态
sudo service nginx stop #停止服务
sudo service nginx start #启动服务
启动之后,打开http://localhost/即可.如果不能访问,先不要继续,看看是什么原因,解决之后再继续。
- 配置
nginx
cd /etc/nginx/conf.d
sudo vim nexus.conf
将下列内容复制进去
#
# The default server
#
server {
listen 80 ;
server_name 127.0.0.1;
#charset koi8-r;
#access_log logs/host.access.log main;
# Load configuration files for the default server block.
location /nexus {
proxy_set_header Via "nginx";
proxy_read_timeout 120;
proxy_send_timeout 120;
proxy_connect_timeout 120;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8081/nexus;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
重启nginx
sudo service restart nginx
如果你的机器同时安装了Apache,此时nginx都可能启动不了,这是因为它们都是用了80这个端口。两种方法:停止apache或者将nginx的端口修改为8080,将nexus.conf配置文件中的 listen 80改为listen 8080
启动成功之后,访问http://127.0.0.1/nexus即可.
配置nexus
- 配置
nexus开启远程索引 新搭建的neuxs环境只是一个空的仓库,需要手动和远程中心库进行同步,nexus默认是关闭远程索引下载,最重要的一件事情就是开启远程索引下载。登陆nexus系统,默认用户名密码为admin/admin123。
点击左侧的Views/Repositories,下拉菜单中有Repositories选项,点击Repositories,找到右边仓库列表中的三个仓库Apache Snapshots,Codehaus Snapshots和Central,然后在这三个仓库的configuration下把Download Remote Indexes修改为true。然后在这三个仓库上分别右键,选择Repair Index,这样nexus就会去下载远程的索引文件。
-
建立内部仓库 新建公司的内部仓库,步骤为页面上部的
Add –> Hosted Repository,在页面的下半部分输入框中填入Repository ID和Repository Name即可,比如分别填入myrepo和my repository,另外把Deployment Policy设置为Allow Redeploy,点击save就创建完成了. -
修改
neuxs仓库组nexus中仓库组的概念是Maven没有的,在Maven看来,不管你是hosted也好,proxy也好,或者group也好,对我都是一样的,我只管根据groupId,artifactId,version等信息向你要构件。为了方便Maven的配置,nexus能够将多个仓库,hosted或者proxy合并成一个group,这样,Maven只需要依赖于一个group,便能使用所有该group包含的仓库的内容。
neuxs中默认自带了一个名为Public Repositories组,点击该组可以对他保护的仓库进行调整。同时创建一个Group ID为public-snapshots、Group Name为Public Snapshots Repositories的组,把Apache Snapshots、Codehaus Snapshots和Snapshots加入其中。
到这里neuxs的安装配置就完成了.
二、
搭建Nexus:
要先装好jdk
下载地址:http://www.sonatype.org/nexus/archived_version?id=38
|
1
2
3
|
[root@MiWiFi-R1CM-srv src]
# wget
[root@MiWiFi-R1CM-srv src]
# tar -zxf nexus-2.9.0-bundle.tar.gz -C /usr/local/
[root@MiWiFi-R1CM-srv src]
# mv /usr/local/nexus-2.9.0-bundle /usr/local/nexus
|
配置nexus(根据需要配置nexus监听的端口号):
|
1
|
sed
-i
's/application-port=8081/application-port=8088/g'
nexus
/conf/nexus
.properties
|
启动方法一、
配置环境变量(RUN_AS_USER=root)表示使用root运行nexus:
|
1
2
3
4
|
[root@MiWiFi-R1CM-srv ~]
# echo -e '#!/bin/bash\nexport NEXUS_HOME=/usr/local/nexus\nexport PATH=$PATH:$NEXUS_HOME/bin\nexport RUN_AS_USER=root' >/etc/profile.d/nexus.sh
[root@MiWiFi-R1CM-srv ~]
# source /etc/profile.d/nexus.sh
[root@MiWiFi-R1CM-srv
local
]
# /usr/local/nexus/bin/nexus start
[root@MiWiFi-R1CM-srv
local
]
# netstat -tlunp |grep 8088
|
tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN 2671/java
启动方法二(service)、
step1(拷贝启动脚本)
|
1
2
|
[root@MiWiFi-R1CM-srv
local
]
# cd /usr/local/nexus/
[root@MiWiFi-R1CM-srv nexus]
# cp bin/jsw/linux-x86-64/nexus /etc/init.d/
|
step2(修改脚本)
|
1
|
[root@MiWiFi-R1CM-srv nexus]
# vim /etc/init.d/nexus
|
新增六行参数
|
1
2
3
4
5
6
|
# chkconfig: 2345 66 39
# description: running&stop nexus service.
RUN_AS_USER=root
NEXUS_HOME=
/opt/pht/nexus-2
.5.1-01
PLATFORM=linux-x86-64
PLATFORM_DIR=
"${NEXUS_HOME}/bin/jsw/${PLATFORM}"
|
修改三行参数
|
1
2
3
|
WRAPPER_CMD=
"${PLATFORM_DIR}/wrapper"
WRAPPER_CONF=
"${PLATFORM_DIR}/../conf/wrapper.conf"
PIDDIR=
"${NEXUS_HOME}"
|
编辑warpper配置文件
|
1
|
[root@MiWiFi-R1CM-srv nexus]
# vim /usr/local/nexus/bin/jsw/linux-x86-64/../conf/wrapper.conf
|
修改一行参数:
修改前:
|
1
|
wrapper.java.
command
=java
|
修改后(你的jdk安装目录):
|
1
|
wrapper.java.
command
=
/usr/jdk1
.7.0_67
/bin/java
|
step3(增加执行权限)
|
1
|
[root@MiWiFi-R1CM-srv nexus]
# chmod +x /etc/init.d/nexus
|
step4(交给chkconfig管理)
|
1
|
[root@MiWiFi-R1CM-srv nexus]
# chkconfig --add nexus
|
step5(启动)
|
1
|
[root@MiWiFi-R1CM-srv nexus]
# service nexus start
|
step6(排错)
|
1
2
|
[root@MiWiFi-R1CM-srv nexus]
# ps -ef |grep nexus
root 12762 34939 0 10:08 pts
/2
00:00:00
grep
nexus
|
nexus进程刚开始会出现,过一会就没有了,继续查看连接状态
|
1
2
|
[root@MiWiFi-R1CM-srv nexus]
# netstat -tlun |grep 7777
[root@MiWiFi-R1CM-srv nexus]
#
|
没有连接,查看wrapper日志文件
启动报错解决:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
wrapper | --> Wrapper Started as Daemon
wrapper | Launching a JVM...
wrapper | Unable to start JVM: No such
file
or directory (2)
wrapper | JVM exited
while
loading the application.
wrapper | Reloading Wrapper configuration...
wrapper | Launching a JVM...
wrapper | Unable to start JVM: No such
file
or directory (2)
wrapper | JVM exited
while
loading the application.
jvm 2 | wrapper | Unable to start JVM: No such
file
or directory (2)
wrapper | Reloading Wrapper configuration...
wrapper | Launching a JVM...
wrapper | Unable to start JVM: No such
file
or directory (2)
wrapper | JVM exited
while
loading the application.
jvm 3 | wrapper | Unable to start JVM: No such
file
or directory (2)
wrapper | Reloading Wrapper configuration...
wrapper | Launching a JVM...
wrapper | Unable to start JVM: No such
file
or directory (2)
wrapper | JVM exited
while
loading the application.
jvm 4 | wrapper | Unable to start JVM: No such
file
or directory (2)
wrapper | Reloading Wrapper configuration...
wrapper | Launching a JVM...
wrapper | Unable to start JVM: No such
file
or directory (2)
wrapper | JVM exited
while
loading the application.
jvm 5 | wrapper | Unable to start JVM: No such
file
or directory (2)
wrapper | There were 5 failed launches
in
a row, each lasting
less
than 300 seconds. Giving up.
wrapper | There may be a configuration problem: please check the logs.
wrapper | <-- Wrapper Stopped
|
wrapper配置文件中没有指定jdk的安装路径,修改之。
wrapper.java.command=/usr/jdk1.7.0_67/bin/
继续报错:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
wrapper | --> Wrapper Started as Daemon
wrapper | Launching a JVM...
wrapper | Unable to start JVM: Permission denied (13)
wrapper | JVM exited
while
loading the application.
wrapper | Reloading Wrapper configuration...
wrapper | Launching a JVM...
wrapper | Unable to start JVM: Permission denied (13)
wrapper | JVM exited
while
loading the application.
jvm 2 | wrapper | Unable to start JVM: Permission denied (13)
wrapper | Reloading Wrapper configuration...
wrapper | Launching a JVM...
wrapper | Unable to start JVM: Permission denied (13)
wrapper | JVM exited
while
loading the application.
jvm 3 | wrapper | Unable to start JVM: Permission denied (13)
wrapper | Reloading Wrapper configuration...
wrapper | Launching a JVM...
wrapper | Unable to start JVM: Permission denied (13)
wrapper | JVM exited
while
loading the application.
jvm 4 | wrapper | Unable to start JVM: Permission denied (13)
wrapper | Reloading Wrapper configuration...
wrapper | Launching a JVM...
wrapper | Unable to start JVM: Permission denied (13)
wrapper | JVM exited
while
loading the application.
jvm 5 | wrapper | Unable to start JVM: Permission denied (13)
wrapper | There were 5 failed launches
in
a row, each lasting
less
than 300 seconds. Giving up.
wrapper | There may be a configuration problem: please check the logs.
wrapper | <-- Wrapper Stopped
|
wrapper配置文件中指定java绝对路径,而不是jdk的bin路径。。。修改之。
wrapper.java.command=/usr/jdk1.7.0_67/bin/java
这次ok了。
访问nexus:
http://192.168.31.123:8088/nexus/
2065

被折叠的 条评论
为什么被折叠?



