Nexus—基于Linux主机搭建私服

下载与安装

1、下载地址

https://help.sonatype.com/repomanager3/product-information/download
https://help.sonatype.com/en/download-archives---repository-manager-3.html

2、安装jdk

apt update
apt install openjdk-17-jdk

需要注意的是必须使用apt进行安装,否则后续在使用systemd进行管理服务的时候,需要在systemd的配置文件中添加java的环境变量。

3、解压nexus到指定目录

tar zxvf nexus-3.76.0-03-unix.tar.gz -C /data

4、创建nexus用户并将相应的目录指定nexus为所有者

useradd -M -r -s /bin/false nexus
chown -R nexus.nexus /data/nexus-3.76.0-03 
chown -R nexus.nexus /data/sonatype-work

5、创建systemd配置文件

# vim /etc/systemd/system/nexus.service

[Unit]
Description=Nexus Repository Manager
After=network.target

[Service]
Type=forking
User=nexus
Group=nexus
ExecStart=/data/nexus-3.76.0-03/bin/nexus start
ExecStop=/data/nexus-3.76.0-03/bin/nexus stop
Restart=on-abort

[Install]
WantedBy=multi-user.target

6、启动服务

systemctl enable nexus
systemctl start nexus

7、更换中心私服

https://repo1.maven.org/maven2/
更换为
https://maven.aliyun.com/repository/public

留下评论

您的邮箱地址不会被公开。 必填项已用 * 标注