$ wget https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.6.2-omnibus.5.3.0.ci.1-1_amd64.deb
$ sudo apt-get install openssh-server
$ sudo apt-get install postfix # Select 'Internet Site'
$ sudo dpkg -i gitlab_7.6.2-omnibus.5.3.0.ci.1-1_amd64.deb
$ sudo gitlab-ctl reconfigure
如此一來,預設 http://localhost/ 就可以登入查看了。然而,預設環境比較適合體驗啦,我又多做了幾個動作,包含也在系統裝上 Ruby2.0 方便未來的相關使用。
更新 Gitlab 環境:
$ sudo vim /etc/gitlab/gitlab.rb
# 對外 Web 資訊
external_url = 'http://YourPublicDomainName'
# 對外 SSH 資訊
gitlab_rails['gitlab_ssh_host'] = 'YourPublicDomainName'
# 時區
gitlab_rails['time_zone'] = 'Asia/Taipei'
# 開啟 https 服務, 以及強制使用 https
nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80
nginx['ssl_certificate'] = "/etc/gitlab/ssl/YourPublicDomainName.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/YourPublicDomainName.key"
$ sudo gitlab-ctl reconfigure
$ sudo gitlab-ctl restart
更新 Postfix 環境:
$ sudo vim /etc/postfix/main.cf
myhostname = YourPublicDomainName
$ sudo postfix reload
安裝 Ruby 2.0 (非必要):
$ sudo apt-get update
$ sudo apt-get install ruby2.0 ruby2.0-dev
$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
$ gem -v
1.8.23
$ sudo ln -sf /usr/bin/ruby2.0 /usr/bin/ruby
$ sudo ln -sf /usr/bin/gem2.0 /usr/bin/gem
$ ruby -v
ruby 2.0.0p384 (2014-01-12) [x86_64-linux-gnu]
$ gem -v
2.0.14
以上則是稍微完整一點的調整。
然而,有時為了確保服務長久性,會有一些變動方式,例如 gitlab 資料儲存在於 /var/opt/gitlab ,可以給予一個獨立空間維護,因此,在安裝 gitlab 軟體前,先自行把 /var/opt/gitlab 擺在額外的 partition (此例是 AWS EC2 管理,給予一個 64GB 空間: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html ):
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 20G 0 part /
xvdb 202:16 0 4G 0 disk /mnt
xvdc 202:32 0 64G 0 disk
$ sudo mkfs -t ext4 /dev/xvdc
$ sudo mkdir /64GB
$ sudo mount /dev/xvdc /64GB
$ sudo mkdir -p /64GB/gitlab /var/opt
$ sudo ln -s /64GB/gitlab /var/opt/gitlab
接著再跑安裝 gitlab 流程...如果已經安裝了,那就是配置好 /64GB 後:
$ sudo gitlab-ctl stop
ok: down: logrotate: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: postgresql: 0s, normally up
ok: down: redis: 1s, normally up
ok: down: sidekiq: 0s, normally up
ok: down: unicorn: 0s, normally up
$ sudo cp -a /var/opt/gitlab /64GB/gitlab
$ sudo mv /var/opt/gitlab /var/opt/gitlab-bak
$ sudo ln -s /64GB/gitlab /var/opt/gitlab
$ sudo gitlab-ctl start
沒有留言:
張貼留言