環境準備:
操作系統:Centos7
內存:2G以上
磁盤:50G
安全:關閉防火墻,selinux
1、安裝GitLab所需依賴
?yum -y install policycoreutils openssh-server openssh-clients postfix
2、設置postfix開機自啟
?sudo systemctl enable postfixsudo systemctl start postfixsudo systemctl status postfix
3. 安裝GitLab倉庫(可選)
?# 為了方便安裝,你可以添加GitLab的官方倉庫。curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
4. 安裝GitLab CE(社區版)
?sudo EXTERNAL_URL="http://192.168.131.128" yum install -y gitlab-ce-12.0.3-ce.0.el7.x86_64
5. 配置GitLab
?# 編輯配置文件sudo vim /etc/gitlab/gitlab.rb?# 修改以下參數(根據實際需求調整):external_url 'http://192.168.131.128:8181' ?# 設置訪問地址和端口git_data_dirs({ "default" => { "path" => "/data/gitlab/data" } }) ?# 自定義倉庫存儲路徑(需提前創建目錄)?# 保存并退出后,重載配置sudo gitlab-ctl reconfigure
6. 啟動 GitLab 服務
?# 啟動 GitLabsudo gitlab-ctl start?# 檢查服務狀態sudo gitlab-ctl status#gitlab管理命令gitlab-ctl startgitlab-ctl stopgitlab-ctl stop postgresqlgitlab-ctl restartgitlab-ctl statusgitlab-ctl reconfigure #配置重載gitlab-ctl tail #查看服務日志gitlab-ctl tail redis
7. 訪問 GitLab
在瀏覽器中訪問 http://192.168.131.128。首次登錄時,設置管理員密碼(用戶名默認為 root)。初始密碼可通過以下命令查看(24 小時后失效):sudo cat /etc/gitlab/initial_root_password
8. gitlab漢化配置
漢化地址:https://gitlab.com/xhang/gitlab
?登錄 GitLab。 ?點擊右上角頭像 → Preferences。 ?滾動到 Localization 部分,選擇 簡體中文。 ?保存并刷新頁面。