不包含發(fā)布相關(guān)配置。涉及maven和npm白魂、yarn砾莱。
下載
官方下載頁:https://www.sonatype.com/nexus/repository-oss-download
傳送門: https://pan.baidu.com/s/1wFRGv37bjJz6B2UrzS3e9A 提取碼: 35rv
安裝
解壓(假定解壓后的路徑是d:\nexus)蔓搞,里面有兩個文件夾:sonatype-work和nexus-3.29.2-02
可選配置
創(chuàng)建\nexus\sonatype-work\nexus3\etc\nexus.properties
# 自定義 web 訪問端口
application-port=8081
# 自定義 Web 上下文路徑 (以 / 開頭胰丁,不要以 / 結(jié)尾)
nexus-context-path=/
運行
cd d:\nexus\nexus-3.29.2-02\bin
nexus /run
開始運行會等待一段時間才準(zhǔn)備好。
注冊系統(tǒng)服務(wù)
管理員運行cmd, 切換到 nexus-3.15.2-01/bin 目錄
nexus.exe /install #進(jìn)行安裝, 成功后會提示 Installed service 'nexus
nexus.exe /start #啟動服務(wù)
停止服務(wù)
Nexus /stop
卸載服務(wù)
Nexus /uninstall
登錄
瀏覽器輸入地址localhost:8081
占擊左上角Sign In败明,輸入用戶名admin和密碼(密碼在synatype-work/nexus3/admin.password)隘马,登錄后文件將被自動刪除
重新設(shè)置密碼
在Configure Anonymous Access彈窗中選擇Enable anonymous access
最后點擊Finish按鈕
配置maven倉庫
添加maven庫
左側(cè)Repository->Repositories->點擊Create repository按鈕->選擇Maven2(proxy)->輸入Name:maven-aliyun, remote storage 填寫https://maven.aliyun.com/nexus/content/groups/public/,點擊下方Create Repository按鈕
創(chuàng)建maven-hosted倉庫
選擇Maven-public倉庫,將剛建的代理倉庫maven-hosted和maven-aliyun添加到Members妻顶。注意:hosted庫在proxy庫之前酸员。
maven客戶端配置
用戶配置文件 ~/.m2/settings.xml:
<mirrors>
<mirror>
<!--This sends everything else to maven-public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<!-- http://[ip]:[port][/nexus-context-path]/repository/[public-repository-name] -->
<url>http://localhost:8081/repository/maven-public</url>
</mirror>
</mirrors>
配置npm庫
添加npm庫
左側(cè)Repository->Repositories->點擊Create repository按鈕->選擇 npm(proxy)->輸入 Name: npm-proxy, remote storage 填寫 https://registry.npm.taobao.org 或 https://registry.npmjs.org. 用于將包情求代理到地址地址
點擊Create repository按鈕,增加 npm(hosted) 輸入 Name: npm-hosted 用于存放自己的私有包
再次點擊Create repository按鈕.,增加npm(group) 輸入 Name: npm-public, 下面Member repositories里選擇之前添加的2個移動右邊讳嘱。注意:hosted庫在proxy庫之前幔嗦。
設(shè)置全局npm私服
npm config set registry http://localhost:8081/repository/npm-public/
驗證npm私服
npm init -y
npm --loglevel info install axios
讓yarn使用私服
yarn config set registry http://localhost:8081/repository/npm-public/
以下可視情況配置
..> npm login always-auth
Username: admin
Password:
Email: (this IS public) admin@example.org
Logged in as admin on http://localhost:8081/repository/npm-public/.
確保yarn使用nexus私服的其它參考(視情況,非必須):
- remove .yarnrc and .npmrc file
- run command yarn config delete registry to delete current registry url from yarn inner config
- Create .npmrc with following content
registry=https://nexus-registry-url
always-auth=true
_auth=<base64-token-value>