linux系統之上搭建maven 之nexus服務篇
今天剛好有點時間,就想在公司的服務器搭建一個私服,以便以后可以唯我所用,當然前提是服務器最好可以上網,否則還需要配置代理服務器,前兩天剛好把服務器的網絡給配置了下,這邊就不詳述了!大家一定著急了吧,稍安務燥,這就進入正題,O(∩_∩)O~
linux安裝過程和window主機還是差別挺大的。
1.下載nexus集成版
到這個地方http://www.sonatype.org/nexus/go 下載壓縮包,我這邊下載的是nexus-2.0.3-bundle.tar.gz這個版本。
2. 解壓到相應的目錄
tar -xzvf nexus-2.0.3-bundle.tar.gz , 我這邊放在/home/linjx/opendev/nexus-2.0.3目錄下。
3. 設置為系統服務
這里需要使用root權限,具體請看http://books.sonatype.com/nexus-book/reference/install-sect-service.html
簡單如下:
# cd /etc/init.d
# cp /home/linjx/opendev/nexus-2.0.3/bin/jsw/linux-x86-64/nexus ./nexus
# chmod 755 nexus
# chkconfig --add nexus
# chkconfig --levels 345 nexus on
4. 編輯/etc/init.d/nexus的文本
4.1. 添加以下變量
RUN_AS_USER=linjx ## 這個主要為了后面使用,不需要使用root用戶啟動服務
NEXUS_HOME=/home/linjx/opendev/nexus-2.0.3/
PLATFORM=linux-x86-64
PLATFORM_DIR="${NEXUS_HOME}/bin/jsw/${PLATFORM}"
4.2. 修改以下變量
WRAPPER_CMD="${PLATFORM_DIR}/wrapper"
WRAPPER_CONF="${PLATFORM_DIR}/../conf/wrapper.conf"
PIDDIR="${NEXUS_HOME}"
5. 啟動服務
切換會自己的用戶,不需要使用root用戶;
# service nexus start
這個大家出現什么情況,是不是失敗了!界面上出現 :Could not write pid file /etc/rc.d/init.d/./nexus.pid: Permission denied通過查看日志文件:
fzdev#[/home/linjx/opendev/nexus-2.0.3/logs] cat w*
wrapper | ERROR: Could not write pid file /etc/rc.d/init.d/./nexus.pid: Permission denied
怎么辦呢,根據信息提示,nexus.pid無法寫入,應該還是權限問題,這個應該跟啟動當前服務有關。
查文檔http://books.sonatype.com/nexus-book/reference/install-sect-service.html后發現,一有段信息沒有配置,
Change PIDDIR to a directory where this user has read/write permissions. In most Linux distributions, /var/run is only writable by root. The properties you need to add to customize the PID file location is "wrapper.pid". For more information about this property and how it would be configured in wrapper.conf, see: http://wrapper.tanukisoftware.com/doc/english/properties.html
大概意思就是服務啟動時無法寫入pid,就是說init.d這個目錄當前用戶是沒有權限寫的,怎么辦呢。可以自定義pid寫入目錄,那么在哪里配置呢,是不是又想起了wrapper.conf了,其他文檔中也說明了。
好吧,那就再加個配置吧,這樣:PIDDIR="/home/linjx/piddir"
然后再啟動服務,果然成功了!具體可以看看附件中的詳細的日志!
6. 啟動之后,可以登錄首頁查看nexus的界面
http://192.168.1.26:8081/nexus/index.html
默認管理員用戶名/密碼: admin/admin123
posted on 2013-08-21 09:32 javalinjx 閱讀(14957) 評論(2) 編輯 收藏 所屬分類: java