5.linux系统搭建npm私服

linux系统npm私服搭建

搭建环境:centos7 需要4核cpu

一、安装基础环境

1.安装Java(直接用yum安装)

[root@test ~]# yum install java -y

2.查看Java是否安装好

[root@test ~]# java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

二、安装nexus

1.下载nexus

下载地址:https://www.sonatype.com/download-oss-sonatype (点击OSS下载最新版本)

2.解压

[root@test ~]# tar xf nexus-3.23.0-03-unix.tar.gz  -C /usr/local/

3.修改配置文件(可选,如果端口冲突可以修改端口,默认8081)

#端口
[root@test ~]# vim /usr/local/nexus-3.23.0-03/etc/nexus-default.properties
application-port=8081

#数据存储路径
[root@test ~]# vim /usr/local/nexus-3.23.0-03/bin/nexus.vmoptions
-Xms1200M
-Xmx1200M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3   #数据存储路径
-Dkaraf.log=../sonatype-work/nexus3/log
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false

4.增加用户(可选)

[root@test ~]# useradd nexus
[root@test ~]# chown -R nexus:nexus /usr/local/nexus-3.23.0-03
[root@test ~]# chown -R nexus:nexus /usr/local/sonatype-work/

如果使用的root用户运行会有警告

img

5.设置启动用户(可选)

[root@test ~]# vim /usr/local/nexus-3.23.0-03/bin/nexus.rc
run_as_user="nexus"

6.修改 ulimit(可选)

#修改ulimit最大文件限制数
[root@test ~]# echo ulimit -n 65536 >>/etc/profile
[root@test ~]# source /etc/profile
#查看
[root@test ~]# ulimit -n
65536

7.启动/停止

[root@test ~]# su nexus
[nexus@grafana root]$ 
/usr/local/nexus-3.14.0-04/bin/nexus start/stop/status/run

8.查看监听

[root@test ~]# netstat -lntp | grep 8081
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      8563/java  

三、npm私服搭建

浏览器输入 http://localhost:8081 进入管理界面,默认账号密码 admin 密码在:/usr/local/sonatype-work/nexus3/admin.password(登录的时候登录界面会告诉你,登录进去之后记得先修改密码)

登录进去的页面

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

这里创建一个npm组、一个npm代理(代理到https://registry.npm.taobao.org)、一个本地npm

1.创建npm代理

在这里插入图片描述

2.创建本地npm

在这里插入图片描述
3.创建npm组

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
4.配置node的仓库地址

1) 首先查看nodejs的默认仓库地址

[root@test ~]# npm config get registry
https://registry.npmjs.org/

2) 查看搭建好的npm私服地址

在这里插入图片描述

#注意IP地址是你搭建服务的IP或者是域名
#添加本地源
[root@test ~]# npm config set registry http://111.111.111.111:8082/repository/npm-group/
#查看本地源
[root@test ~]# npm config get registry
http://111.111.111.111:8082/repository/npm-group/

在这里插入图片描述

至此搭建完毕。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值