介绍
Nexus Repository Oss是什么?
官网简介:
The free artifact repository with universal format support.
包存储仓库的免费工具,可以用来存储jar, docker, npm等软件包,也可以存储其他文件格式,不依赖mysql等,下载包可直接运行。
支持的工具列表
准备
安装Openjdk 8
sudo apt install openjdk-8-jdk
安装
下载 Nexus
https://www.sonatype.com/download-oss-sonatype
创建文件夹
sudo cd /opt/ && mkdir nexus &&cd nexus
解压
sudo tar -zxvf nexus-3.24.0-02-unix.tar.gz
重命名
sudo mv nexus-3.24.0-02 /opt/nexus/nexus-3.24.0-02
sudo mv sonatype-work/ /opt/nexus/sonatype-work
启动 Nexus
cd /opt/nexus/nexus-3.24.0-02/bin/
sudo ./nexus run
开启启动
建立软连接
bin sudo ln -s /opt/nexus/nexus-3.24.0-02/bin/nexus /etc/init.d/nexus
修改Nexus
权限
sudo chmod 755 /etc/init.d/nexus
设置Nexus
为系统服务:
sudo update-rc.d nexus defaults
验证是否可以运行服务
sudo systemctl status nexus.service
● nexus.service - LSB: nexus
Loaded: loaded (/etc/init.d/nexus; generated)
Active: active (running) since Sun 2020-06-21 10:37:14 CST; 1min 57s ago
Docs: man:systemd-sysv-generator(8)
Process: 158628 ExecStart=/etc/init.d/nexus start (code=exited, status=0/SUCCESS)
Tasks: 68 (limit: 4485)
Memory: 1.4G
CGroup: /system.slice/nexus.service
└─158845 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -server -Dinstall4j.jvmDir=/usr/lib/jvm/java-8-openjdk-amd64/jre -Dexe4j.moduleName=/opt/ne>
编写nexus.service
文件
cd /etc/systemd/system/
sudo touch nexus.service
[Unit]
Description=nexus service
After=network.target
[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus/nexus-3.24.0-02/bin/nexus start
ExecStop=/opt/nexus/nexus-3.24.0-02/bin/nexus stop
Restart=on-abort
TimeoutSec=600
[Install]
WantedBy=multi-user.target
重新加载进程
sudo systemctl daemon-reload
设置 Nexus
开机自启动命令为
sudo systemctl enable nexus.service
禁止 Nexus
开机自启动命令为
sudo systemctl disable nexus.service
修改启动JDK版本(可选)
INSTALL4J_JAVA_HOME_OVERRIDE=xxx
修改默认端口(可选)
cd /opt/nexus/nexus-3.24.0-02/etc/
vim nexus-default.properties
默认端口8081
application-port=8081
开始使用
浏览器输入http://ip:8081
进入Nexus控制台页面,开始使用吧!!!
Npm私服搭建
参考这篇文章即可:Nexus 搭建npm 私服