1. Install Node environment
a、官网下载 tar 包
b、解压设置环境变量
# vim /etc/profile
PATH=/usr/local/node/bin:$PATH
2. Install sinopia
# npm install -g sinopia
3. Manually start the service for the first time to generate a configuration file
# sinopia
Sinopia doesn't need superuser privileges. Don't run it under root.
warn --- config file - /root/.config/sinopia/config.yaml
warn --- http address - http://0.0.0.0:4873/
4. Modify the configuration file
# vim /root/.config/sinopia/config.yaml
# grep -v "^$" config.yaml | grep -v "^\s*#"
storage: /home/sinopia/storage
auth:
htpasswd:
file: /home/sinopia/htpasswd
max_users: -1
uplinks:
npmjs:
url: http://registry.npm.taobao.org
packages:
'@*/*':
access: $all
publish: $authenticated
'*':
access: $all
publish: $authenticated
proxy: npmjs
logs:
- {type: stdout, format: pretty, level: http}
- {type: file, path: /home/sinopia/logs/sinopia.log, level: info}
listen: 0.0.0.0:4873 # 默认没有,只能本机localhost访问,添加后可以通过外网访问
5. Install pm2 for background startup
# npm install -g pm2
6. Use pm2 to start sinopia
# pm2 start `which sinopia`
# pm2 ls
7. Install nrm to manage mirror sites
# npm install -g nrm
# nrm ls
# nrm add cloudpath http://172.20.47.76:4873
# nrm use cloudpath
8. Add users
# npm adduser --registry http://172.20.47.76:4873
9. Try to publish a package
# mkdir test
# cd test
# npm init -y
# npm publish
10. Open the page to view
http://172.20.47.76:4873/
The effect is as follows:
Reference:
https://github.com/rlidwka/sinopia
https://www.cnblogs.com/czf-zone/p/6860457.html