搭建Maven私服

來源:互聯網
上載者:User

安裝Nexus服務的文檔可以參考官方網站:http://www.sonatype.com/books/nexus-book/reference/install-sect-install.html

首先確保JDK1.6已經安裝,我用的是openjdk.

1.下載並安裝Nexus

在Ubuntu 12.04 server上,下載Nexus最新版本。和官方文檔不一樣的地方是,我將nexus放在了/usr而不是/usr/local目錄下。

 

[plain] view plaincopyprint?
  1. wget http://www.sonatype.org/downloads/nexus-2.0.4-1-bundle.tar.gz 
wget http://www.sonatype.org/downloads/nexus-2.0.4-1-bundle.tar.gz

 

mv nexus-oss-webapp-2.0.4-1-bundle.tar.gz /usr/
cd /usr
tar zxvf nexus-oss-webapp-2.0.4-1-bundle.tar.gz
ln -s nexus-oss-webapp-2.0.4-1 nexus

為了日後方便,按照官方文檔的方式設定一個環境變數,將下面的指令碼添加到/etc/environment檔案最後

NEXUS_HOME=/usr/nexus

RUN_AS_USER=root

注意:

a. /etc/environment檔案裡面export不是必須的,可以沒有

b./etc/environment設定的環境變數整個系統有效,Ubuntu推薦使用,不推薦用/etc/profile,我試過/etc/profile,沒有效果

c.使用了/etc/environment,如果root使用者沒有啟用,當從其他使用者通過sudo -s切換到root許可權的時候,/etc/environment設定的環境變數會消失。因此要啟用root

2.運行

進入/usr/nexus/bin/目錄,運行下面的命令:

sudo -s

./nexus start
Starting Nexus OSS...
Started Nexus OSS.

預設nexus採用內建jetty作為web伺服器,監聽本地連接埠8081.通過開啟網頁http://km9983.gicp.net:8081/nexus進行測試,使用者名稱和密碼預設是:admin/admin123

3.建立系統服務

複製Nexus內建的指令碼到/etc/init.d目錄

root@ubuntu1110:/etc/init.d# cp $NEXUS_HOME/bin/jsw/linux-x86-64/nexus ./

添加幾個變數到nexus指令碼中

NEXUS_HOME=/usr/nexus

RUN_AS_USER=root

PLATFORM=linux-x86-64

如果你用的不是系統內建的JRE,要加上。

#JAVA_HOME=/usr/jdk1.6.0_30

#PATH="$JAVA_HOME/bin:$PATH

修改幾個變數的值:

# Wrapper

WRAPPER_CMD=$NEXUS_HOME/bin/jsw/$PLATFORM/wrapper

WRAPPER_CONF=$NEXUS_HOME/bin/jsw/conf/wrapper.conf

# Location of the pid file.                                                                                                                  
PIDDIR=/var/run

這個修改後的指令碼要好好儲存,這種事情再幹一次很無聊。
之後,運行命令:
root@ubuntu1110:/etc/init.d# update-rc.d nexus defaults
update-rc.d: warning: /etc/init.d/nexus missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
Adding system startup for /etc/init.d/nexus ...
   /etc/rc0.d/K20nexus -> ../init.d/nexus
   /etc/rc1.d/K20nexus -> ../init.d/nexus
   /etc/rc6.d/K20nexus -> ../init.d/nexus
   /etc/rc2.d/S20nexus -> ../init.d/nexus
   /etc/rc3.d/S20nexus -> ../init.d/nexus
   /etc/rc4.d/S20nexus -> ../init.d/nexus
   /etc/rc5.d/S20nexus -> ../init.d/nexus

Ok.現在可以通過service nexus start啟動,

然後通過tail -f /usr/nexus/logs/wrapper.log 來檢查啟動狀態。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.