日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CentOS 7 安装nexus

發布時間:2025/3/19 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CentOS 7 安装nexus 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

1、下載nexus ,使用版本nexus-3.13.0-01-unix.tar.gz,下載地址

https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.13.0-01-unix.tar.gz

2、解壓后移動到安裝目錄(/opt/nexus)

創建安裝目錄

[root@ou Downloads]# mkdir /opt/nexus/

解壓安裝包到安裝目錄:

[root@ou Downloads]# tar -zxvf nexus-3.13.0-01-unix.tar.gz -C /opt/nexus/

切換到安裝目錄:

[root@ou Downloads]# cd /opt/nexus

查看目錄詳情:

[root@ou nexus]# ls nexus-3.13.0-01 sonatype-work

解壓縮后可以看到有兩個文件夾,第一個是nexus服務,第二個是它的私有倉庫目錄。 這時已經可以啟動 nexus

進入位置:NEXUS_HOME/bin

本示例位置:

/opt/nexus/nexus-3.13.0-01/bin

進入bin目錄:

[root@ou nexus]# cd nexus-3.13.0-01/bin [root@ou bin]# ./nexus start **************************************** WARNING - NOT RECOMMENDED TO RUN AS ROOT **************************************** If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.

當用root權限運行時會彈出提示,解決方式是

[root@ou bin]# vim nexus 在配置文件上部找到 #RUN_AS_USER= 在下一行添加 RUN_AS_USER=root 具體示例: # the JVM and is not useful in situations where a privileged resource or # port needs to be allocated prior to the user being changed. #RUN_AS_USER= RUN_AS_USER=root

3、設置系統服務

3.1、添加 NEXUS_HOME 環境變量

vim /etc/profile

在后面添加

export NEXUS_HOME=/opt/nexus/nexus-3.13.0-01

使新加入的內容生效

source /etc/profile

3.2、添加本地jdk

vim /opt/nexus/nexus-3.13.0-01/bin/nexus

在文件中找到 INSTALL4J_JAVA_HOME_OVERRIDE 這一行(這一行默認被注釋),添加上自己的JDK路徑

INSTALL4J_JAVA_HOME_OVERRIDE=/usr/java/jdk1.8.0_181-amd64

3.3、配置以 nexus 用戶啟動應用

nexus 官網建議不要使用 root 帳戶啟動應用,所以創建一個 nexus 用戶

useradd nexus

修改 nexus 配置,使用 nexus 作為應用啟動的帳戶

gedit /opt/nexus/nexus-3.13.0-01/bin/nexus.rc

將內容修改為

run_as_user=”nexus”

修改 nexus 的目錄權限

chown nexus nexus

3.4、設置系統服務(systemd)

vi /usr/lib/systemd/system/nexus.service [Unit] Description=nexus After=network.target[Service] Type=forking ExecStart=/opt/nexus/nexus-3.13.0-01/bin/nexus start ExecReload=/opt/nexus/nexus-3.13.0-01/bin/nexus stop ExecStop=/opt/nexus/nexus-3.13.0-01/bin/nexus stop PrivateTmp=true[Install] WantedBy=multi-user.target 然后執行 systemctl daemon-reload,重新加載服務 再執行 systemctl enable nexus,使該服務可以開機自啟。 啟動服務 systemctl start nexus

4、登陸管理界面

默認管理地址為:http://localhost:8081/nexus/ 使用界面右上角log in進行默認用戶的登陸, 默認用戶為:admin,密碼為:admin123。

5、點擊左側的users查看當前系統的用戶。

可以看到一共三個用戶,admin,deployment和anonymous。 admin:該用戶擁有Nexus的全部權限,默認密碼為admin123。 deployment:該用戶能夠訪問Nexus,瀏覽倉庫內容、搜索、上傳部署構件,但是不能對Nexus進行任何配置,默認密碼為deployment123。 anonymous:該用戶對應了所有未登錄的匿名用戶,它們可以瀏覽倉庫并進行搜索

6、集成Maven 打開本地 %M2_HOME%\conf\settings.xml 文件 6.1、設置本地倉庫位置

<localRepository>/opt/apache-maven-3.5.4/repository</localRepository>

6.2、設置 Server

<server><id>nexus-releases</id><username>admin</username><password>admin123</password> </server> <server><id>nexus-snapshots</id><username>admin</username><password>admin123</password> </server>

6.3、設置 Nexus 鏡像(localhost 修改為安裝 Nexus 的服務器地址)

<mirror><id>nexus</id><mirrorOf>*</mirrorOf><url>http://localhost:8081/repository/maven-public/</url> </mirror>

6.4、設置 Profile(localhost 修改為安裝 Nexus 的服務器地址)

<profile><id>nexus-resp</id><repositories><repository><id>nexus-releases</id><url>http://localhost:8081/repository/maven-releases/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></repository><repository><id>nexus-snapshots</id><url>http://localhost:8081/repository/maven-snapshots/</url><releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>nexus-plugin</id><url>http://localhost:8081/repository/maven-public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository></pluginRepositories> </profile>

6.5、設置默認激活的 profile

<activeProfiles><activeProfile>nexus-resp</activeProfile> </activeProfiles>

6.6、修改工程pom文件

<distributionManagement><repository><id>nexus-releases</id><name>Team Nexus Release Repository</name><url>http://localhost:8081/repository/maven-releases/</url></repository><snapshotRepository><id>nexus-snapshots</id><name>Team Nexus Snapshot Repository</name><url>http://localhost:8081/repository/maven-snapshots/</url></snapshotRepository> </distributionManagement><repositories><repository><id>nexus-public</id><name>Nexus public Repository</name><url>http://localhost:8081/repository/maven-public</url></repository> </repositories>

操作完成,執行 mvn deploy,應該就可以 Nexus 上查找到你當前項目了。

轉載于:https://my.oschina.net/ouyushan/blog/1935515

總結

以上是生活随笔為你收集整理的CentOS 7 安装nexus的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。