1)下载
- # cd /usr/local/src/
- # wget http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz
- # tar -zxvf nexus-latest-bundle.tar.gz
- # mv /usr/local/src/nexus-2.14.1-01 /usr/local/nexus
- # rm -rf sonatype-work/
2)配置
- # vi /usr/local/nexus/bin/nexus
- NEXUS_HOME="/usr/local/nexus"
- RUN_AS_USER="nexus"
- PIDDIR=${NEXUS_HOME}
- # vi /usr/local/nexus/conf/nexus.properties
- application-port=8081
- nexus-work=${bundleBasedir}/sonatype-work/nexus
- # vi /usr/local/nexus/bin/jsw/conf/wrapper.conf
- wrapper.java.maxmemory=768
3)修改用户
- # groupadd nexus
- # useradd nexus -g nexus
- # cd /usr/local/
- # chown -R nexus:nexus nexus
4)测试配置
- # /usr/local/nexus/bin/nexus console
- Started InstrumentedSelectChannelConnector@0.0.0.0:8081
- # /usr/local/nexus/bin/nexus stop
5)启动服务
- # cp /usr/local/nexus/bin/nexus /etc/init.d/nexus
- # chmod 755 /etc/init.d/nexus
- # service nexus start
- Starting Nexus OSS...
- Started Nexus OSS.
- # tail -f /usr/local/nexus/logs/wrapper.log
6)设置代理服务
管理页面URL:http://<IP>:8081/nexus
账户:admin / admin123
通过 Views/Repositories -> Repositories -> Add -> Proxy Repository,创建以下两个代理:
<Maven代理仓库>
引用
Repository ID :proxied-maven-repo
Repository Name :proxied-maven-repo
Provider :Maven2
Remote Storage Location :http://maven.aliyun.com/nexus/content/groups/public/
Repository Name :proxied-maven-repo
Provider :Maven2
Remote Storage Location :http://maven.aliyun.com/nexus/content/groups/public/
<NPM代理仓库>
引用
Repository ID :proxied-npm-repo
Repository Name :proxied-npm-repo
Provider :npm
Remote Storage Location :https://registry.npm.taobao.org/
Repository Name :proxied-npm-repo
Provider :npm
Remote Storage Location :https://registry.npm.taobao.org/
引用
代理仓库地址:
http://<IP>:8081/nexus/content/repositories/proxied-maven-repo/
http://<IP>:8081/nexus/content/repositories/proxied-npm-repo/
7)测试确认:
<Maven代理仓库确认>
C:\Users\rensanning\.m2\settings.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <settings>
- <mirrors>
- <mirror>
- <id>my-repo</id>
- <mirrorOf>*</mirrorOf>
- <url>http://<IP>:8081/nexus/content/repositories/proxied-maven-repo/</url>
- </mirror>
- </mirrors>
- </settings>
- # mvn package
<NPM代理仓库确认>
- # npm config set registry http://<IP>:8081/nexus/content/repositories/proxied-npm-repo/
- # npm install -g underscore
<下载文件确认>
- # cd /usr/local/nexus
- # ll sonatype-work/nexus/storage/proxied-maven-repo
- # ll sonatype-work/nexus/storage/proxied-npm-repo
<下载日志确认>
- # tail -f /usr/local/nexus/sonatype-work/nexus/logs/request.log