天天看點

Gitlab安裝配置及簡單問題處理一、安裝二、解除安裝gitlab三、使用已有Nginx其他配置遇到的問題及解決

Git 是版本控制系統

Github 是線上的基于Git的代碼托管服務

Gitlab 可以在上面建立免費的私人repo

建議(少走彎路)

1、Gitlab本身很容易安裝,整個安裝包也就300M,下載下傳到安裝不到半小時

2、不過因為環境的不一樣,可能導緻很多意想不到的問題,網上的教程很多,方式大緻都一樣,環境不一樣,配置方式也不一樣,是以最好找一台新機器,會減少很多問題

3、如果裝置上已經安裝了Nginx,那麼配置的時候就直接禁用Nginx,參看本頁第三條

4、一般情況都采用預設配置就行,這家夥啟動了好多個程序,修改多了反而不好

一、安裝

方式一

gitlab提供的安裝方式(可能速度較慢):

https://about.gitlab.com/install/#centos-6

方式二:

1、安裝GitLab依賴包

yum install -y curl policycoreutils-python openssh-server openssh-clients      

2、下載下傳GitLab的rpm包

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.6-ce.0.el7.x86_64.rpm      

3、通過yum本地安裝GitLab

yum -y localinstall gitlab-ce-10.0.6-ce.0.el7.x86_64.rpm       

4、配置

$ vim /etc/gitlab/gitlab.rb 
$ grep "^external_url" /etc/gitlab/gitlab.rb

external_url 'http://127.0.0.1'   # 綁定監聽的域名或IP(企業中最好是域名)      

5、啟動

# 初始化
$ gitlab-ctl reconfigure

# 啟動
$ gitlab-ctl start      

6、常用指令

gitlab-ctl reconfigure   # 初始化
gitlab-ctl start         # 啟動
gitlab-ctl stop          # 停止
gitlab-ctl status        # 狀态
gitlab-ctl restart       # 重新開機
gitlab-ctl tail          # 日志      

二、解除安裝gitlab

1、停止gitlab

gitlab-ctl stop      

2、檢視gitlab程序

ps aux | grep gitlab      

3、解除安裝gitlab

yum remove gitlab-ce      

5、删除所有包含gitlab檔案

find / -name gitlab | xargs rm -rf      

參考

Linux上Gitlab解除安裝

三、使用已有Nginx

解決方式:UNIX套接字 更改為 TCP端口

配置gitlab

$ vim /etc/gitlab/gitlab.rb

# nginx['enable'] = true
nginx['enable'] = false

gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"      

配置Nginx反代代理

$ vim /etc/nginx/conf.d/gitlab.conf 

server {
    listen       80;
    server_name  _;

    location / {
        proxy_pass http://127.0.0.1:8181;
    }
}
      

生效重新開機

gitlab-ctl reconfigure 
gitlab-ctl restart

nginx -t
nginx -s reload      
Gitlab 自帶Nginx與原Nginx沖突的解決方案

其他配置

1、郵箱配置

gitlab搭建與基本使用
$ gitlab-rails console 
> Notify.test_email('[email protected]', 'Message Subject', 'Message Body').deliver_now      

2、檢視gitlab版本

cat /opt/gitlab/embedded/service/gitlab-rails/VERSION      

3、修改實際ip

vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml      

4、通過簡單伺服器測試端口是否對外開放

python -m SimpleHTTPServer 8000      

遇到的問題及解決

1、頁面顯示502,可能的問題

(1) 記憶體不足:首先恭喜你,配置基本正确,官方推薦配置:2核心+4GB 實體記憶體

參考:

安裝GitLab的需求

2、gitlab 郵箱配置後, 發郵件報錯

EOFError: end of file reached      

解決:

如果使用25端口,不配ssl

如果使用465端口,應該配置如下

gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'none'      

測試

$ gitlab-rails console

>Notify.test_email('[email protected]',"sdfsdf", 'dsf').deliver_now      
gitlab 郵箱配置後, 發郵件報錯 EOFError: end of file reached

其他參考

  1. 私有倉庫GitLab快速入門篇
  2. Linux下軟體安裝與解除安裝:rpm和yum工具
  3. gitlab的安裝以及一些簡單的配置
  4. GItLab 部署

繼續閱讀