Linux Nexus 安裝

NEXUS 介紹

nexus 是java開發中maven組件的私有庫,對於團隊開發是必不可少的支撐服務html

NEXUS安裝

咱們先上NEXUS 官網查找最新的NEXUS安裝包。nexus-repository-oss下載java

[thinktik@host nexus3]$ wget https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.16.1-02-unix.tar.gz
[thinktik@host nexus3]$ tar -zxvf nexus-3.16.1-02-unix.tar.gz 
[thinktik@host nexus3]$ ls
nexus-3.16.1-02  nexus-3.16.1-02-unix.tar.gz  sonatype-work
# nexus 須要java環境,建議JDK1.8
[thinktik@host nexus3]$ java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
[thinktik@host nexus3]$  cd /home/thinktik/nexus3/nexus-3.16.1-02/bin
[thinktik@host bin]$ ls
contrib  nexus  nexus.rc  nexus.vmoptions
# 第一次啓動,建議這樣看啓動過程,及時發現問題
[thinktik@host bin]$ ./nexus run
# 沒有問題的話,使用這個啓動nexus服務,這樣nexus會在後臺啓動服務
[thinktik@host bin]$ ./nexus start

NEXUS配置修改

nexus下降內存佔用nginx

通常nexus默認的配置對機器的內存要求比較高,對於我的開發者學習用的低價雲服務器來說是沒有必要給這麼多資源的,要麼形成無謂的浪費要麼因爲機器內存有限致使nexus沒法啓動。我建議通常我的開發和學習按照我這個配置來,儘可能下降機器硬件要求。安全

-Xms100M
-Xmx330M
-XX:MaxDirectMemorySize=220M
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false

NGINX代理

neuxs 啓動後默認監聽的是計算機的8081端口,你能夠使用ip:端口的方式直接訪問neuxs。不過不建議你們在服務器上暴露過多的端口,以避免引發安全問題。使用nginx代理轉發neuxs服務的方式會更安全也更方便一些。這裏我使用域名轉發的方式實現對nexus的服務代理。服務器

server { 
    listen 80; 
    server_name nexus.missioncenter.online;
    rewrite ^(.*)$  https://$host$1 permanent;
   }

    server {
     listen 443;
     server_name nexus.missioncenter.online;
     ssl on;
     root html;
     index index.html index.htm;
     ssl_certificate   /home/thinktik/env/nginx/cert/nexus_cert.pem;
     ssl_certificate_key  /home/thinktik/env/nginx/cert/nexus_cert.key;
     ssl_session_timeout 5m;
     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
     ssl_prefer_server_ciphers on;
     location / {
         proxy_pass  http://127.0.0.1:8081;
         proxy_redirect  off;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For
         $proxy_add_x_forwarded_for;
         proxy_set_header X-Forwarded-Proto "https";
     }
    }

本文原創連接: Linux Nexus 安裝session

相關文章
相關標籤/搜索