一、环境要求:
- 装有JDK
二、安装软件
1.下载链接:
2.解压软件:
tar -zxvf nexus-3.15.1-01-unix.tar.gz
3.移动包到/usr/local目录下
mv nexus-3.15.1-01 /usr/local -rf
4.创建一个用户
sudo useradd -rm nexus
chown -R nexus.nexus /usr/local/nexus-3.15.1-01/
5.创建服务:
vim /etc/systemd/system/nexus.service
插入下面内容
[Unit]
Description=nexus service
After=network.target
[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/usr/local/nexus-3.15.1-01/bin/nexus start
ExecStop=/usr/local/nexus-3.15.1-01/bin/nexus stop
User=nexus
Restart=on-abort
[Install]
WantedBy=multi-user.target
使服务生效并开机自启
sudo systemctl daemon-reload
sudo systemctl enable nexus.service
sudo systemctl start nexus.service
6.启动:
systemctl start nexus
7.配置方向代理:
apache:
ProxyRequests Off
ProxyPreserveHost On
<VirtualHost *:80>
ServerName repo.example.com
ServerAdmin admin@example.com
AllowEncodedSlashes NoDecode
ProxyPass /nexus http://localhost:8081/nexus nocanon
ProxyPassReverse /nexus http://localhost:8081/nexus
ErrorLog logs/repo.example.com/nexus/error.log
CustomLog logs/repo.example.com/nexus/access.log common
</VirtualHost>
Nginx:
http {
proxy_send_timeout 120;
proxy_read_timeout 300;
proxy_bufferingoff;
keepalive_timeout 5 5;
tcp_nodelayon;
server {
listen *:80;
server_name repo.example.com;
# allow large uploads of files
client_max_body_size 1G;
# optimize downloading files larger than 1G
# proxy_max_temp_file_size 2G;
location /nexus {
# Use IPv4 upstream address instead of DNS name to avoid attempts by nginx to use IPv6 DNS lookup
proxy_pass http://127.0.0.1:8081/nexus;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
更多请查看:run-behind-a-reverse-proxy
8.更改nexus目录:
vim /usr/local/nexus-3.15.1-01/bin/nexus.vmoptions
更改下面三个路径到你想要的路径下:
-Dkaraf.data=/opt/sonatype-work/nexus3
-Djava.io.tmpdir=/opt/sonatype-work/nexus3/tmp
-XX:LogFile=/opt/sonatype-work/nexus3/log/jvm.log
完美Ending
更多详情,请看官方文档:
sonatypeDoc
评论 (0)