1. 程式人生 > >轉載:centos安裝gitlab詳解

轉載:centos安裝gitlab詳解

smtp發送郵件 下載 ror mage package nload git clone 輸入 clas

原文地址:http://blog.csdn.net/jiangtao_st/article/details/73612298

一, 服務器快速搭建gitlab方法

可以參考gitlab中文社區 的教程
centos7安裝gitlab:https://www.gitlab.cc/downloads/#centos7
centos6安裝gitlab:https://www.gitlab.cc/downloads/#centos6
如下方法按照官網來操作,手工安裝過於麻煩。當前測試平臺為小鳥雲的三個月centos 7測試機.
1. 安裝配置依賴項

如想使用Postfix來發送郵件,在安裝期間請選擇’Internet Site’. 您也可以用sendmai或者 配置SMTP服務 並 使用SMTP發送郵件.
在 Centos 6 和 7 系統上, 下面的命令將在系統防火墻裏面開放HTTP和SSH端口.

  1. sudo yum install curl policycoreutils openssh-server openssh-clients
  2. sudo systemctl enable sshd
  3. sudo systemctl start sshd
  4. sudo yum install postfix
  5. sudo systemctl enable postfix
  6. sudo systemctl start postfix
  7. sudo firewall-cmd --permanent --add-service=http
  8. sudo systemctl reload firewalld

這裏可以自己yum 一個iptables做處理,一樣的效果。
2. 添加GitLab倉庫,並安裝到服務器上

  1. curl -sS http://packages.gitlab.cc/install/gitlab-ce/script.rpm.sh | sudo bash
  2. sudo yum install gitlab-ce

如果你不習慣使用命令管道的安裝方式, 你可以在這裏下載 安裝腳本 或者 手動下載您使用的系統相應的安裝包(RPM/Deb) 然後安裝

  1. curl -LJO https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-XXX.rpm
  2. rpm -i gitlab-ce-XXX.rpm

3. 啟動GitLab

  1. sudo gitlab-ctl reconfigure

下邊就可以訪問了:在瀏覽器輸入虛擬機的ip
技術分享
重置下密碼。使用root用戶進行登錄。登錄效果如下:
技術分享

註意事項以及異常故障排查:
1,按照該方式,我安裝了一個確實沒問題,只不過是英文版。沒有經過漢化。
2,默認安裝登錄需要重置root密碼。可以自己單獨設置一個復雜密碼後登錄。
3,gitlab本身采用80端口,如安裝前服務器有啟用80,安裝完訪問會報錯。需更改gitlab的默認端口。
修改vim /etc/gitlab/gitlab.rb:

  1. external_url ‘http://localhost:90‘

4,unicorn本身采用8080端口,如安裝前服務器有啟用8080,安裝完訪問會報錯。需更改unicorn的默認端口。
修改 /etc/gitlab/gitlab.rb:

  1. unicorn[‘listen‘] = ‘127.0.0.1‘
  2. unicorn[‘port‘] = 3000

unicorn[‘listen‘] = ‘127.0.0.1‘
unicorn[‘port‘] = 8082
 

nginx[‘listen_addresses‘] = [‘*‘]
nginx[‘listen_port‘] = 82 # override only if you use a reverse proxy: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#setting-the-nginx-listen-port

5,每次重新配置,都需要執行sudo gitlab-ctl reconfigure 使之生效。
6,日誌位置:/var/log/gitlab 可以進去查看訪問日誌以及報錯日誌等,供訪問查看以及異常排查。
gitlab-ctl tail #查看所有日誌
gitlab-ctl tail nginx/gitlab_access.log #查看nginx訪問日誌

二,gitlab中文漢化【如不清楚gitlab版本以及git,請不要操作,否則gitlab癱瘓】
1,需要下載漢化包,我們這裏直接到去git一個。如果沒安裝git的請自行yum或apt-get 一個git。
比如我們現在到/usr/local/src,執行如下命令去git clone包:

  1. git clone https://github.com/larryli/gitlabhq.git

2,停止當前gitlab

  1. gitlab-ctl stop
  2. \cp /usr/local/src/gitlabhq/* /opt/gitlab/embedded/service/gitlab-rails/ -rf

其中有兩個提示我們可以忽略:
cp: cannot overwrite non-directory `/opt/gitlab/embedded/service/gitlab-rails/log’ with directory `./log’
cp: cannot overwrite non-directory `/opt/gitlab/embedded/service/gitlab-rails/tmp’ with directory `./tmp’
好了,漢化完成,重新啟動gitlab,漢化完成。

三,日常管理

gitlab-ctl start|stop|status|restart
比如查看狀態:

    1. [[email protected] gitlab]# gitlab-ctl status
    2. run: gitlab-workhorse: (pid 19922) 665s; run: log: (pid 19159) 725s
    3. run: logrotate: (pid 19179) 723s; run: log: (pid 19178) 723s
    4. run: nginx: (pid 19166) 724s; run: log: (pid 19165) 724s
    5. run: postgresql: (pid 19026) 760s; run: log: (pid 19025) 760s
    6. run: redis: (pid 18943) 766s; run: log: (pid 18942) 766s
    7. run: sidekiq: (pid 19149) 732s; run: log: (pid 19148) 732s
    8. run: unicorn: (pid 20257) 642s; run: log: (pid 19116) 734s

轉載:centos安裝gitlab詳解