Gitlab deployment and localization

Author:Mr.Gao

Introduction to Git

GitLab is an open source version control system, is a code hosting, testing, deployment in one of the open-source git repository management software, can be accessed by public or private project web interface. And Github similar, GitLab can browse the code, management deficiencies and comments. Management team can access to the repository, it is very easy to browse submitted version, and provides a historical document library. Is a very popular easy to use development version control system.

Git has three categories are :

  1. Git: is the local version control system tools.
  2. Github: is the official online repository hosting the code, can be registered for use on their own, https://github.com .
  3. GitLab: is its own self-built warehouse an unofficial version. The popular thing is within the company.

Here we need to give a share is to build their own Git repository, which is Gitlab.

Gitlab hardware or have certain requirements, because Gitlab multiple job tasks and processes, memory is required, it is recommended 1cpu above, more than 2G of memory.

deploy

On the eve of preparation :
We will proceed with the practice under Centos 7

  1. Turn off the firewall
  2. Close SELinux
  3. Close NetworkManager
$ sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 
$ setenforce 0
$ systemctl stop NetworkManager
$ systemctl disable NetworkManager 
$ systemctl disable firewalld
$ systemctl stop firewalld

1. Configure yum source (recommended)

Add gitlab source, I've used the source of Tsinghua University

$ cp -fr /etc/yum.repos.d /etc/yum.repos.d.bak

$ cat >/etc/yum.repos.d/gitlab-ce.repo <<EOF
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
EOF

2. Install

Installing some git Kit

$ yum makecache
$ yum -y install curl policycoreutils openssh-server openssh-clients postfix  cronie git wget patch
$ systemctl restart postfix
$ systemctl enable postfix
$ #yum install gitlab-ce git    #自动安装最新版
$ yum install gitlab-ce-12.3.5 git -y    #安装指定版本,我这里选用了v12.3.5

Installed

Configuration GitLab

1, load the configuration

After installation is complete, you first load the configuration will be very slow, be patient like, until loading is complete.

如果一直卡在ruby_block[......] action run,处理方法:
按住CTRL+C强制结束
运行:$ sudo systemctl restart gitlab-runsvdir
再次执行:$ sudo gitlab-ctl reconfigure

注意:在配置gitlab之前保证80端口没有被占用

$ gitlab-ctl reconfigure

加载完成后,开始启动Gitlab,GitLab默认会占用80、8080和9090端口,如果条件不允许使用80端口,请看下一节,否则可以忽略

$ gitlab-ctl restart
$ gitlab-ctl status

开户访问web界面
第一次访问,系统会要求重置新密码,管理员的用户名为root

登录完成,点击右上角的Settings进行Preferences设置,在语言项选择中文,此时刷新后,可以看到标题和右侧的导航栏是变为中文的,但是具体的项目并没有中文显示,所以会变成中文+英文的LOW爆显示,后面将会介绍通过补丁/包进行gitlab完美汉化的教程。如图:

2、修改git默认访问端口

首先,停用gitlab,$ gitlab-ctl stop

gitlab.rb

用于gitlab如何调用80和8080的服务等

$ cp -fr /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.gao-`date +%Y%m%d`
$ sed -i 's#gitlab.example.com#YOUR_IP:12580#g'  /etc/gitlab/gitlab.rb    # "$YOUR_IP"请自行修改
$ vim /etc/gitlab/gitlab.rb
nginx['listen_port'] = 12580
nginx['listen_https'] = false
nginx['listen_addresses'] = ['*']
unicorn['listen'] = '127.0.0.1'
unicorn['port'] = 8088
prometheus['listen_address'] = 'localhost:9099'

unicorn.rb

$ cp -fr /var/opt/gitlab/gitlab-rails/etc/unicorn.rb{,.gao-`date +%Y%m%d`}
$ sed -i 's#8080#8088#g' /var/opt/gitlab/gitlab-rails/etc/unicorn.rb

gitlab-http.conf

这个文件是gitlab内置的nginx的配置文件,里面可以影响到nginx真实监听端口号。

$ cd /var/opt/gitlab/nginx/conf/
$ cp -fr gitlab-http.conf gitlab-http.conf.gao-`date +%Y%m%d`
$ vim gitlab-http.conf    #修改以下几行内容
listen *:12580;
server_name YOUR_IP;
set $http_host_with_default "YOUR_IP";

giltab-shell

$ vim /var/opt/gitlab/gitlab-shell/config.yml
gitlab_url: "http://127.0.0.1:8088"    #unicorn_port

3. 代码发布地址(域名)

$ vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
gitlab:
  ## Web server settings (note: host is the FQDN, do not include http://)
  host: YOUR_IP
  port: 12580
  https: false

4. 服务验证

$ gitlab-ctl reconfigure
$ gitlab-rake gitlab:check SANITIZE=true --trace    #配置检查
$ gitlab-ctl restart
$ gitlab-ctl tail    #日志输出,可用于排错

访问git地址:http://YOUR_IP:12580

至此!gitlab安装完成,下面讲一下如何进行汉化


汉化Gitlab(more)

下载对应版本的汉化包
Gitlab默认语言是英文,对于想加强英文的同学,建议继续使用英文,但要求使用中文,这里需要下载一个汉化包

如果要下载指定版本的汉化包,命令如下:

$ cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
12.3.5
$ wget https://gitlab.com/xhang/gitlab/-/archive/v12.3.5-zh/gitlab-v12.3.5-zh.tar.gz
$ tar -zxf gitlab-v12.3.5-zh.tar.gz

下载完成后,将下载的文件夹内容复制到gitlab目录下,复制前先停止Gitlab

$ gitlab-ctl stop

覆盖文件进行汉化

汉化包和你的gitlab版本一定要一样

$ cp -fr /opt/gitlab/embedded/service/gitlab-rails{,gao-`date +%Y%m%d`}    ##备份原文件
$ \cp -rf ./gitlab-v12.3.5-zh/* /opt/gitlab/embedded/service/gitlab-rails/

复制时可能不断提示是否要覆盖,这时可能是系统每次执行cp命令时,其实是执行了cp -i命令的别名。出现这种情况可以修改~/.bashrc,在“alias cp=’cp -i’”前加#注释,再刷新文件 source ~/.bashrc

在复制过程中提示,以下信息是正常的:

cp: cannot overwrite non-directory ‘/opt/gitlab/embedded/service/gitlab-rails/log’ with directory ‘./log’
cp: cannot overwrite non-directory ‘/opt/gitlab/embedded/service/gitlab-rails/tmp’ with directory ‘./tmp’

复制完成后,需要重新加载配置,并启动Gitlab

$ gitlab-ctl reconfigure    
$ gitlab-ctl restart

再次访问gitlab页面,就可以显示中文界面,如图:

 






Guess you like

Origin www.cnblogs.com/sunhongleibibi/p/12072689.html