GitLab的安裝及使用教程


GitLab 社區版 8.8.5

https://gitlab.com/xhang/gitlab GitLab 中文社區版

/etc/gitlab/gitlab.rb          #gitlab配置文件
/opt/gitlab                    #gitlab的程序安裝目錄
/var/opt/gitlab                #gitlab目錄數據目錄
/var/opt/gitlab/git-data       #存放倉庫數據
gitlab-ctl reconfigure         #重新加載配置
gitlab-ctl status              #查看當前gitlab所有服務運行狀態
gitlab-ctl stop                #停止gitlab服務
gitlab-ctl stop nginx          #單獨停止某個服務
gitlab-ctl tail                #查看所有服務的日志

Gitlab的服務構成:
nginx:                 靜態web服務器
gitlab-workhorse        輕量級反向代理服務器
logrotate              日志文件管理工具
postgresql             數據庫
redis                  緩存數據庫
sidekiq                用於在后台執行隊列任務(異步執行)
sudo yum install gitlab-ce-8.8.5

https://www.cnblogs.com/niuben/p/10867877.html GitLab的安裝及使用教程

gitlab的配置

配置文件位置 /etc/gitlab/gitlab.rb

[root@centos7 test]# vim /etc/gitlab/gitlab.rb

[root@centos7 test]# grep "^[a-Z]" /etc/gitlab/gitlab.rb

external_url 'http://10.0.0.51'  # 這里一定要加上http://

# 配置郵件服務
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "hgzerowzh@qq.com"  # 自己的qq郵箱賬號
gitlab_rails['smtp_password'] = "xxx"  # 開通smtp時返回的授權碼
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"   
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = "hgzerowzh@qq.com"  # 指定發送郵件的郵箱地址
user["git_user_email"] = "shit@qq.com"   # 指定接收郵件的郵箱地址

修改好配置文件后,要使用 gitlab-ctl reconfigure 命令重載一下配置文件,否則不生效。

gitlab-ctl reconfigure # 重載配置文件

Gitlab常用命令

gitlab-ctl start         # 啟動所有 gitlab 組件
gitlab-ctl stop          # 停止所有 gitlab 組件
gitlab-ctl restart       # 重啟所有 gitlab 組件
gitlab-ctl status        # 查看服務狀態

gitlab-ctl reconfigure   # 啟動服務
gitlab-ctl show-config   # 驗證配置文件

gitlab-ctl tail          # 查看日志

gitlab-rake gitlab:check SANITIZE=true --trace    # 檢查gitlab

 vim /etc/gitlab/gitlab.rb # 修改默認的配置文件

修改gitlab默認端口

gitlab默認需要使用80 8080 等端口,我的centos上有使用這些端口的其他軟件;所以必須更改。

步驟如下:

1. 修改 gitlab.yml

進入目錄: /var/opt/gitlab/gitlab-rails/etc

將gitlab.yml 中的host和port修改成自己需要的

production: &base
  #
  # 1. GitLab app settings
  # ==========================

  ## GitLab settings
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    #host: gitlab.example.com
    #port: 80
    host: IP地址或者域名
    port: 設定端口號1,如8000

    https: false

這里的端口號1 與nginx(gitlab自帶的nginx,見下面2)監聽的端口號 要相同,這是提供給外部瀏覽器訪問的端口。

2. 修改 gitlab nginx配置

找到 /var/opt/gitlab/nginx/conf/gitlab-http.conf

它是gitlab內置的nginx的配置文件,里面可以影響到nginx真實監聽端口號。要與上面的端口號1設置成一樣。(位置略靠下)

server {
  #listen *:80;
  listen *: 8000;

3. 修改 unicorn.rb

此文件所在目錄與gitlab.yml相同: /var/opt/gitlab/gitlab-rails/etc/unicorn.rb

# What ports/sockets to listen on, and what options for them.
#listen "127.0.0.1:8080", :tcp_nopush => true
listen "127.0.0.1:端口號2,如9080", :tcp_nopush => true

這里的端口號2 是gitlab-rails本身的端口號,gitlab-rails是gitlab內部的后台服務。

4. giltab-shell修改

進入目錄:/var/opt/gitlab/gitlab-shell

修改:config.yml

# Url to gitlab instance. Used for api calls. Should end with a slash.
#gitlab_url: "http://127.0.0.1:8080"
gitlab_url: "http://127.0.0.1:9080"

這里設置成端口號2即可。

5. 重啟gitlab

以上修改完成后,重啟下,就可以訪問8000端口的gitlab了。

gitlab-ctl restart


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM