自動化部署-1、GitLab搭建

一、 依賴包安裝

1、安裝policycoreutils-python openssh-server

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd

2、安裝postfix

sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

二、 安裝GitLab-ce

ce爲免費版本,使用tsinghua源安裝比較快。

1、tsinghua源下載地址
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

2、安裝
rpm -ivh gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
安裝輸出如下:

warning: gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:gitlab-ce-10.0.0-ce.0.el7        ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ \`/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

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

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

三、 配置

1、url和nginx設置
1)、打開配置文件
vi /etc/gitlab/gitlab.rb
修改如下:

external_url 'http://gitlab.xxxx.com'
nginx['listen_addresses'] = ['0.0.0.0', '[::]']
nginx['listen_port'] = 70

重新加載配置
gitlab-ctl reconfigure

打開70端口,默認爲80端口,域名後不需要跟端口,改成其他端口後域名後都需要跟端口。

firewall-cmd --zone=public --add-port=70/tcp --permanent
firewall-cmd --reload

2)、重啓gitlab
gitlab-ctl restart

3)、測試
本地hosts添加映射

192.168.3.27  gitlab.xxxx.com

訪問http://gitlab.szztbi.com:70/
第一次會出現設置密碼界面,設置好密碼後登陸,用戶名爲root

2、郵箱設置
1)、修改配置文件
vi /etc/gitlab/gitlab.rb
如下:

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "xxxxxx"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['smtp_domain'] = "smtp.163.com"

重新加載配置
gitlab-ctl reconfigure

2)、測試郵箱
進入控制檯
gitlab-rails console
發送消息

Notify.test_email('[email protected]', 'Message Subject', 'Message Body').deliver_now

3)、其他郵箱配置和詳細信息
https://docs.gitlab.com/omnibus/settings/smtp.html

四、 漢化

1、下載漢化項目
git clone https://gitlab.com/xhang/gitlab.git

2、將漢化不同內容導出
進入剛剛下載的gitlab文件夾
git diff v10.0.0 v10.0.0-zh > ../v10.0.0-zh.diff

3、將補丁加載到GitLab
停止服務
```gitlab-ctl stop``

安裝patch
yum install -y patch

導入
patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < v10.0.0-zh.diff

啓動服務
```gitlab-ctl start``

如果範圍返回503,重新加載配置並重啓即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章