jdk1.8html
/usr/local
文件夹下/usr/local
tar -zxvf jdk-8u211-linux-x64.tar.gz
tar -zxvf nexus-3.10.0-04-unix.tar.gz
此时安装就已经完成了,其实已经能够直接使用root用户启动了,可是为了方便之后管理,我这里添加了一些配置。参考设置
小节。linux
nexus启动时,会产生日志和临时文件等,默认状况下会放在与Nexus安装目录同级文件夹sonatype-work
中(第一次启动会自动生成),现将其默认位置修改成Nexus的根目录下vim /usr/local/nexus-3.10.0-04/bin/nexus.vmoptions
shell
基本参考
高级参考
firewall-cmd --zone=public --add-port=8081/tcp --permanent
vim
Nexus默认端口是8081,它的配置文件在/usr/local/nexus-3.10.0-04/etc/nexus-default.properties
中,能够经过cat
命令查看:app
## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties ## # Jetty section application-port=8081 application-host=0.0.0.0 nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml nexus-context-path=/ # Nexus section nexus-edition=nexus-pro-edition nexus-features=\ nexus-pro-feature
添加https访问的形式涉及到端口设置,假如准备设置8443
为https端口,那么须要修改两个地方:tcp
application-port-ssl=8443
在nexus-args
属性上追加,${jetty.etc}/jetty-https.xml
:ide
注:若是须要将http导向https访问,则追加
jetty-http-redirect-to-https.xml
至nexus-args
,这里我没有强制。
此时也别忘记开防火墙:firewall-cmd --zone=public --add-port=8443/tcp --permanent
工具
keystore.jks
的配置,咱们使用脚本生成,其中涉及keytool
工具使用,所以先保证keytool
能够正常使用:vim /etc/profile
并在合适位置加入shell export JAVA_HOME=/usr/local/jdk1.8.0_211 export PATH=$JAVA_HOME/bin:$PATH
resource /etc/profile
vim /usr/local/nexus-3.10.0-04/nexus-ssl-generate-keystore.sh
```shell
NEXUS_DOMAIN='Nexus'
if [[ -z $1 ]]; then
echo 'please input your ip_address!'
exit
fi
NEXUS_IP_ADDRESS=$1
PASSWORD='password'
keytool -genkeypair -keystore keystore.jks -storepass ${PASSWORD} -keypass \({PASSWORD} -alias nexus -keyalg RSA -keysize 2048 -validity 5000 -dname "CN=\){NEXUS_DOMAIN}, OU=Nexus, O=Nexus, L=Beijing, ST=Beijing, C=CN" -ext "SAN=IP:${NEXUS_IP_ADDRESS}" -ext "BC=ca:true"spa
mv keystore.jks etc/ssl/
#keytool -export -alias nexus -keystore keystore.jks -file keystore.cer -storepass ${PASSWORD}
#mv keystore.cer etc/ssl/.net
生成keystore/usr/local/nexus-3.10.0-04/nexus-ssl-generate-keystore.sh 192.168.197.198
,这里192.168.197.198
是本机IP。
参考
vim /usr/lib/systemd/system/nexus3.service
[Unit] Description=nexus3 - private repository After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/local/nexus-3.10.0-04/bin/nexus start ExecReload=/usr/local/nexus-3.10.0-04/bin/nexus restart ExecStop=/usr/local/nexus-3.10.0-04/bin/nexus stop [Install] WantedBy=multi-user.target
此时使用systemctl enable nexus3
使配置生效便可。
OPTION | COMMAND |
---|---|
启动 | systemctl start nexus3 |
中止 | systemctl stop nexus3 |
重启 | systemctl restart nexus3 |
通常不能直接使用root用户,所以须要为nexus添加用户专门运行:
添加用户:adduser nexus
设置密码:passwd nexus
将拥有者设置为nexus
:chown nexus:nexus -R /usr/local/nexus-3.10.0-04
将nexus
添加至sudoers
:
visudo
nexus ALL=(ALL) ALL
su nexus
sudo systemctl start nexus3
/usr/local/nexus-3.10.0-04/etc/jetty/jetty-https.xml
中会涉及读取keystore.jks
↩