约定:
系统:centos
文件安装位置:/usr/local/nexus
修正记录:
2016-01-25:修正启动服务`PIDDIR`参数配置
下载地址:http://www.sonatype.org/nexus/go/
官方文档:https://books.sonatype.com/nexus-book/reference/index.html
Nexus oss,说说我对这个软件的理解吧,据我所知,java项目在构建过程中需要使用maven构建,而在maven构建时需要用到各种依赖包,这个依赖包需要从maven在线仓库进行下载,官方的仓库地址http://repository.apache.org/snapshots/
http://repo1.maven.org/maven2/
http://nexus.codehaus.org/snapshots/
有时可能因为各种原因无法从在线仓库下载依赖包(如无法访问公网),那这时就需要将依赖包提前下载好传到项目上,而与其这种方式,不如自己部署一个maven在线仓库,将收集的各种依赖包放到这个仓库中,项目再去调用。而如果自己有开发依赖包的能力,也可将依赖包上传到仓库,供第三方使用。
Nexus oss就是构建这种仓库的开源软件,其实apache用的也是Nexus部署的仓库。下载好安装包后,参照官方文档进行安装,
$sudo cp nexus-2.11.4-01-bundle.tar.gz /usr/local
$cd /usr/local
$ sudo tar xvzf nexus-2.11.4-01-bundle.tar.gz
$ sudo ln -s nexus-2.11.4-01 nexus
配置nexus服务
$sudo cp nexus/bin/nexus /etc/init.d/nexus
编辑/etc/init.d/nexus配置
NEXUS_HOME="/usr/local/nexus" #nexus主目录
RUN_AS_USER=web #运行nexus的用户,不能使用root用户
PIDDIR="/var/run" #pid文件目录
这样配置之后就可以使用服务启动和关闭nexus了,加入自启动
chkconfig --add nexus
chkconfig --level 345 nexus on
启动服务就可以通过web页面访问了,
默认地址端口http://localhost:8081/nexus/,默认帐号admin admin123
apache proxy
ProxyRequests Off
ProxyPreserveHost On
<VirtualHost *:80>
ServerName www.example.com
ServerAdmin admin@example.com
ProxyPass /nexus http://localhost:8081/nexus
ProxyPa***everse /nexus http://localhost:8081/nexus
ErrorLog logs/www.example.com/nexus/error.log
CustomLog logs/www.example.com/nexus/access.log common
</VirtualHost>
nginx proxy
http {
proxy_send_timeout 120;
proxy_read_timeout 300;
proxy_buffering off;
keepalive_timeout 5 5;
tcp_nodelay on;
server {
listen *:80;
server_name www.example.com;
# allow large uploads of files - refer to nginx documentation
client_max_body_size 1G
# optimize downloading files larger than 1G - refer to nginx doc before adjusting
#proxy_max_temp_file_size 2G
location /nexus {
proxy_pass http://localhost:8081/nexus;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
nginx ssl
http {
proxy_send_timeout 120;
proxy_read_timeout 300;
proxy_buffering off;
keepalive_timeout 5 5;
tcp_nodelay on;
server {
listen *:443;
server_name repo.example.com;
# allow large uploads of files - refer to nginx documentation
client_max_body_size 1G
# optimize downloading files larger than 1G - refer to nginx doc before adjusting
#proxy_max_temp_file_size 2G
ssl on
ssl_certificate example.pem;
ssl_certificate_key example.key;
location / {
proxy_pass http://localhost:8081/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto "https";
}
}
}
有关页面的配置以及库的添加,可参考官方文档https://books.sonatype.com/nexus-book/reference/config-sect-new-repo.html
有需的可留言给我
转载于:https://blog.51cto.com/morrowind/1713697