GitLab安裝篇-Ubuntu 14.04 LTS

GitLab 是一個用於倉庫管理系統的開源項目。使用Git作爲代碼管理工具,並在此基礎上搭建起來的web服務。它提供Git版本控制、代碼檢查、Bug跟蹤和Wiki,它可以通過LDAP或活動目錄來進行安全認證和授權。單個GitLab可以支持25000個用戶,同時它也可以通過設置多臺服務器來實現其高可用性。GitLab並沒有被收入到Ubuntu14.04軟件庫中,但安裝GitLab卻也十分方便,下面講講如何安裝GitLab:


首先照着GitLab的官方文檔,輸入以下命令:

wget -c https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.0.0-omnibus-1_amd64.deb
sudo apt-get install openssh-server
sudo apt-get install postfix 
sudo dpkg -i gitlab_7.0.0-omnibus-1_amd64.deb

因爲GitLab這個包的地址下載速度很慢,還經常出現斷點,所以在wget後加上了-c這個參數。安裝openssh-server這句其實可以去掉,因爲我一般都是在安裝服務器的時候就勾選安裝了這個服務,畢竟需要遠程登錄服務器嘛!Postfix是郵件服務,如果不安裝這個服務的話,也可以安裝Sendmail或Exim等相似的郵件服務(如果有郵件服務器的話,這一步可以忽略,可以通過gitlab-ctl來重配置SMTP服務)。


接下來是設置GitLab的域名:

sudo mkdir -p /etc/gitlab
sudo touch /etc/gitlab/gitlab.rb
sudo chmod 600 /etc/gitlab/gitlab.rb
sudo vi /etc/gitlab/gitlab.rb

然後添加一條域名配置:

# 下面一定要添加“=”,GitLab自動生成時是沒有這個等號的,結果得到"External URL must include a FQDN"這樣的錯誤提示
external_url="www.hostname.com"
# 如果沒有安裝Postfix或Sendmail這類郵件服務的話,那麼就需要象郵件客戶端那樣根據SMTP服務器的參數來設置以下的內容了
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.server"
gitlab_rails['smtp_port'] = 456
gitlab_rails['smtp_user_name'] = "smtp user"
gitlab_rails['smtp_password'] = "smtp password"
gitlab_rails['smtp_domain'] = "example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true

然後對GitLab進行重配置即可:

sudo gitlab-ctl reconfigure

注意:正如GitLab大多數配置文件(如gitlab.yml或database.yml等)中所註釋的那樣:

# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.

在GitLab中的大部分關於配置方面的修改,現在都需要在/etc/gitlab/gitlab.rb中進行設置,然後再運行sudo gitlab-ctl reconfigure進行修改。


如果對如何配置gitlab.rb有興趣的話,可以參見:https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md 這個網址,基本上已經講得很清楚了。


接下來就是檢測是否安裝成功了,可以輸入下面的命令:

sudo gitlab-ctl status
[sudo] password for firehare: 
run: nginx: (pid 13334) 16103s; run: log: (pid 4244) 22211s
run: postgresql: (pid 4153) 22280s; run: log: (pid 4152) 22280s
run: redis: (pid 4070) 22291s; run: log: (pid 4069) 22291s
run: sidekiq: (pid 4234) 22212s; run: log: (pid 4233) 22212s
run: unicorn: (pid 4212) 22218s; run: log: (pid 4211) 22218s

如果得到與上面相似的結果,那麼說明你安裝成功。


由於GitLab包自帶了Ruby、Rails和PostgreSQL,所以也就不需要象以前那樣考慮兼容性的問題了。最後只需要直接登錄GitLab所在的服務器,並使用帳號root,密碼5iveL!fe來登錄GitLab。首次登錄GitLab會強行讓你重置密碼,然後就可以進入GitLab了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章