ubuntu-18.04 - 如何在 ubuntu-18.04 上安装 nexus
问题描述
我需要在 ubuntu18.04 上安装 nexus-oss 的帮助。我无法在互联网上找到任何 apt-get 命令。
我试图在“sudo apt-get search nexus”中搜索 nexus 包,但无法获得正确的 nexus 版本包。
我在网上浏览过,其中的命令可用于 centos7 但不适用于 Debian os。
在 sonatype 文档中,提供了在 ubuntu 上创建存储库管理器的步骤,是否与在 ubuntu 上安装 nexus 相同?
解决方案
安装 Java
$ sudo apt-get update
$ sudo apt install openjdk-8-jre-headless -y
下载连结
$cd /opt
$ sudo wget https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.16.1-02-unix.tar.gz
$ sudo tar -zxvf nexus-3.16.1-02-unix.tar.gz
$ sudo mv /opt/nexus-3.16.1-02 /opt/nexus
作为一种良好的安全实践,不建议以 root 身份运行 nexus 服务。因此,创建一个名为 nexus 的新用户并授予 sudo 访问权限以管理 nexus 服务。
$ sudo adduser nexus
为nexus用户设置无密码并输入以下命令以编辑sudo文件
$sudo visudo
添加以下行并保存。
nexus ALL=(ALL) NOPASSWD: ALL
更改关联文件的文件和所有者权限
$ sudo chown -R nexus:nexus /opt/nexus
$ sudo chown -R nexus:nexus /opt/sonatype-work
在启动时将 nexus 添加为服务
打开 /opt/nexus/bin/nexus.rc 文件,取消注释 run_as_user 参数并设置如下。
$ sudo vim /opt/nexus/bin/nexus.rc
run_as_user="nexus" (file shold have only this line)
在启动时将 nexus 添加为服务
$ sudo ln -s /opt/nexus/bin/nexus /etc/init.d/nexus
以 nexus 用户身份登录并启动服务
$ su - nexus
$ /etc/init.d/nexus start
使用 netstat 命令检查端口是否正在运行
$ sudo netstat -plnt
允许端口 8081 并访问 nexus http://:8081
以最低默认用户名和密码登录 admin/admin123