CentOS7下yum安裝GitLab-CE


前提准備

建立git用戶

useradd git
passwd git 

關閉防火牆

systemctl stop firewalld
systemctl disabled firewalld

安裝依賴庫

yum install curl openssh-server postfix cronie
service postfix start
chkconfig postfix on

配置yum源進行安裝

注意: gitlab-ce 鏡像僅支持 x86-64 架構

centos中可以直接通過配置yum源然后使用yum進行一鍵安裝
國內可以使用的清華大學的鏡像源安裝GitLab,相關配置及安裝參照:https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
以下內容寫入yum源配置文件:/etc/yum.repos.d/gitlab-ce.repo

# vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
yum makecache
yum install gitlab-ce #自動安裝最新版
# yum install gitlab-ce-x.x.x    #安裝指定版本
# 安裝成功后的提示:
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

默認路徑

一鍵安裝后可以利用rpm -ql gitlab-ce查詢其文件安裝路徑及相關文件路徑,其默認安裝路徑為/opt/gitlab/、程序數據及配置文件保存路徑為/var/opt/gitlab下。
代碼倉庫保存位置:/var/opt/gitlab/git-data/repositories/
代碼倉庫備份位置:/var/opt/gitlab/backups/
postgresql數據及配置目錄:/var/opt/gitlab/postgresql/data/
redis默認配置目錄:/var/opt/gitlab/redis
gitlab主要配置文件:/etc/gitlab/gitlab.rb

常見配置

修改gitlab運行外部URL默認的訪問地址
編輯/etc/gitlab/gitlab.rb

# 未修gitlab.rb配置文件中nginx配置時這個配置默認配置gitlab自帶的nginx端口
external_url 'http://172.17.17.10:81'  

修改之后使用如下命令重新加載配置且同時啟動gitlab所有服務:

gitlab-ctl reconfigure 

瀏覽器訪問:http://172.17.17.10:81,被重定向到密碼修改界面,修改密碼為root的管理員賬戶,修改密碼后自動跳轉到登錄頁面,用root和修改后密碼登錄就可以

GitLab常用命令

gitlab-ctl start    # 啟動所有 gitlab 組件
gitlab-ctl stop        # 停止所有 gitlab 組件
gitlab-ctl restart        # 重啟所有 gitlab 組件
gitlab-ctl status        # 查看服務狀態
gitlab-ctl reconfigure        # 啟動服務
vim /etc/gitlab/gitlab.rb        # 修改默認的配置文件
gitlab-rake gitlab:check SANITIZE=true --trace    # 檢查gitlab
sudo gitlab-ctl tail        # 查看日志
gitlab-ctl --help #查看更多命令

發送郵件配置

gitlab_rails['smtp_enable'] = true  #啟用smtp服務
gitlab_rails['smtp_address'] = "mail.ultrapower.com.cn" #smtp發送服務器
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "xueming@ultrapower.com.cn"
gitlab_rails['smtp_password'] = "12333lzxcl"
gitlab_rails['smtp_domain'] = "ultrapower.com.cn"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = 'xueming@ultrapower.com.cn'#與smtp_user_name一定要一樣
gitlab_rails['gitlab_email_reply_to'] = 'xueming@ultrapower.com.cn'

命令測試:gitlab-rails console

防火牆開放端口

firewall-cmd --zone=public --list-ports #查看開放端口
firewall-cmd --zone=public --add-port=8081/tcp --permanent #開放8081端口
firewall-cmd --reload   #重新加載配置
#如果不需要,也可以直接關閉防火牆
systemctl stop firewalld.service

設置中文界面



刷新界面,就是中文的了


免責聲明!

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



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