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
↩