Nexus Repository下载
根据操作系统选择指定版本,本文针对Linux安装,其他的安装过程可能有所差异。
https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3
安装
建议先创建一个nexus用户,将文件拷贝到/home/nexus
# 按具体下载文件名
tar -zxvf nexus-3.14.0-04-unix.tar.gz
# 按具体解压目录
cd nexus-3.14.0-04/bin
## 启动
./nexus start
# ./nexus stop #停止
# ./nexus status # 查看状态
配置修改
NexusRepository 默认占用8081端口,如果与其他服务有冲突,需要在etc目录下创建一个nexus.properties,具体配置参考nexus-default.properties
## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/
# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
nexus-pro-feature
Nexus不建议在root用户下运行,需要创建用户nexus用户,修改bin/nexus.rc文件
run_as_user="nexus"
开机自启动
开启自启动有init.d和systemd两种方式。
init.d
1.创建一个nexus用户
2.拷贝nexus的软链接到init.d目录
注意:最好再root做自启动配置,省的没权限
# 原文件路径按实际
ln -s /home/nexus/nexus-3.14.0-04/bin/nexus /etc/init.d/nexus
4.1 chkconfig 写法(和4.2二选一)
cd /etc/init.d
chkconfig --add nexus
chkconfig --levels 345 nexus on
4.2 update-rc.d写法(和4.1 二选一)
cd /etc/init.d
sudo update-rc.d nexus defaults
sudo service nexus start
5.切换到nexus用户窗口,启动服务
扫描二维码关注公众号,回复:
4580885 查看本文章
su nexus
service nexus start
systemd
前提是服务器有安装systemd工具,一般cenos7默认安装。
创建一个nexus用户
在/etc/systemd/system/ 目录添加如下文件
nexus.service
[Unit]
Description=nexus service
After=network.target
[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus/bin/nexus start
ExecStop=/opt/nexus/bin/nexus stop
User=nexus
Restart=on-abort
[Install]
WantedBy=multi-user.target
Activate the service with the following commands:
启动服务命令
sudo systemctl daemon-reload
sudo systemctl enable nexus.service
sudo systemctl start nexus.service
查看服务运行日志
tail -f /opt/sonatype-work/nexus3/log/nexus.log