自动化部署-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,重新加载配置并重启即可。

你可能感兴趣的:(运维)