Install Nexus Private Server Repository in Linux Environment

Install Nexus Private Server Repository in Linux Environment

Author: Adon

Public number: Jie Ge's IT journey

Number of texts: 2573 words, 13 pictures, estimated reading time: 7 minutes

Introduction to nexus private server repository
Nexus is a powerful maven repository manager, which greatly simplifies the maintenance of local internal repositories and access to external repositories. , Can also be used to create various private repositories such as yum, pypi, npm, docker, nuget, rubygems, etc.

nexus private server repository installation steps

系统设置
linux中
# /etc/security/limits.conf 在此文件中添加一下内容
nexus - nofile 65536
需要java 1.8以上环境运行

Install the JDK environment

# tar -xzf jdk-8u211-linux-x64.tar.gz -C /usr/local/
# vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_211/
export JRE_HOME=/usr/loca/jdk1.8.0_211/jre
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
# source /etc/profile


Download the nexus installation package

# wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
# mkdir /opt/nexus
# tar -xzf nexus-3.16.1-02-unix.tar.gz -C /opt/nexus
# useradd nexus #以nexus用户运行
# chown -R nexus.nexus /opt/nexus

nexus解压后的两个文件
nexus-xxx nexus运行需要的文件,如运行脚本、依赖jar包
sonatype-work 该目录包含nexus生成的配置文件、日志文件、仓库文件等

优化配置

1) 配置运行用户
# cd /nexus/nexus.x.x.x/bin/
# vim nexus.rc
run_as_user="nexus" ----取消注释

2)可以手动配置jdk的路径
如果不配置的话,会使用默认的JAVA_HOME的环境变量
# cd /nexus/nexus.x.x.x/bin/
# vim nexus
INSTALL4J_JAVA_HOME_OVERRIDE=/usr/local/jdk1.8.0_144 #第14行

3)修改端口
一般使用默认的端口
# cd /nexus/nexusx.x.x.x/bin
# vim nexus-default.properties

4)配置存储及日志位置
一般不做修改,使用默认
# cd /nexus/nexusx.x.x.x/bin/
# vim nexus.vmoptions

After modifying the configuration file, run

# sudo su - nexus
# cd /opt/nexus/nexus.x.x.x/bin
# ./nexus run & #后台运行
# 使用web页面进行设置代理仓库
http://localhost:8081
初始账户及密码:admin/admin123

Configuration of the repository (configuration of the pypi library)

Install Nexus Private Server Repository in Linux Environment

配置pypi仓库步骤:

1、建立官方代理仓库

2、填写远程索引地址时,地址:https://pypi.python.org/ ; http://mirrors.aliyun.com ;https://pypi.tuna.tsinghua.edu.cn; #配置多个国内的资源

3、建立hosted仓库,用于内部使用的myptpi-hosted

4、建立group仓库把官方代理配置添加进去

Install Nexus Private Server Repository in Linux Environment

Install Nexus Private Server Repository in Linux Environment

Install Nexus Private Server Repository in Linux Environment

Install Nexus Private Server Repository in Linux Environment
Install Nexus Private Server Repository in Linux Environment


1、使用pip时,使用-i指定仓库地址,并同时使用--trusted-host参数指定信任主机
pip install -i http://localhost:8081/repository/pypigroup/simple/ --no-cache-dir -r requirements.txt --trusted-host

2、在配置文件中配置私服地址,配置文件地址~/.pip/pip.conf,如不存在则新增该文件。配置文件内容如下
[global]
index-url=nexus.menghuanhua.com:8081/repository/df-pipy-public/simple/
[install]
trusted-host=nexus.menghuanhua.com

Configuration of npm repository

Install Nexus Private Server Repository in Linux Environment


1、创建hosted类型的npm库
storage: Blob store,下拉选择前面的创建好的专用blob
hosted:开发环境,运行重复发布,因此选择allow rede ploy

2、创建proxy类型的仓库
proxy:remote storage:远程仓库地址,填写:https://registry.npm.taobao.org

3、创建group类型的npm仓库
storage:选择装用的blob存储npm-hub
group:将左边可选的2个仓库,添加到右边的members下

Verify use

1、node环境

2、获取默认的仓库地址
# npm config get registry

3、配置私服地址
在nexus的web页面的repositories/group-npm中查看url

4、通过一下的命令配置
# npm config set registry http://x.x.x.x/repository/group-npm
# npm config get reagistry

5、找一个node相关的项目,安装编译
# npm install

End of this article.

Guess you like

Origin blog.51cto.com/15067236/2607574