准备

          
  • 0
  • 1
yum install -y curl openssh-server openssh-clients cronie lokkit lokkit -s http -s ssh

安装 postfix

用于系统邮件的发送

          
  • 0
  • 1
  • 2
yum install postfix service postfix start chkconfig postfix on

安装Gitlab

          
  • 0
  • 1
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash yum install -y gitlab-ce

修改默认端口

          
  • 0
vi /etc/gitlab/gitlab.rb
          
  • 0
nginx['listen_port'] = 8091

配置 https

使用 acme.sh 生成证书

          
  • 0
  • 1
  • 2
external_url 'https://git.xxx.com' nginx['ssl_certificate'] = "/etc/nginx/ssl/fullchain.cer" nginx['ssl_certificate_key'] = "/etc/nginx/ssl/git.xxx.com.key"

应用配置

          
  • 0
gitlab-ctl reconfigure

启动

          
  • 0
gitlab-ctl start

重启

          
  • 0
gitlab-ctl restart

配置系统 nginx 端口转发

          
  • 0
  • 1
  • 2
  • 3
location / { proxy_pass https://localhost:8091; proxy_redirect default; }

汉化

          
  • 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
# 声明版本变量 gitlab_version=$(sudo cat /opt/gitlab/embedded/service/gitlab-rails/VERSION) # 下载储存库 git clone https://gitlab.com/xhang/gitlab.git ~/gitlab-zh cd ~/gitlab-zh # 导出汉化补丁 git diff v${gitlab_version} v${gitlab_version}-zh > ${gitlab_version}-zh.diff # 停止 gitlab sudo gitlab-ctl stop #安装 patch yum install patch -y # 应用补丁 sudo patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 ${gitlab_version}-zh.diff # 重新配置并启动 gitlab gitlab-ctl reconfigure gitlab-ctl restart

配置 smtp 邮件

          
  • 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
vi /etc/gitlab/gitlab.rb # Change the external_url to the address your users will type in their browser external_url 'http://xxhost.com' #Sending application email via SMTP gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.163.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "xxuser@163.com" gitlab_rails['smtp_password'] = "xxpassword" gitlab_rails['smtp_domain'] = "163.com" gitlab_rails['smtp_authentication'] = :login gitlab_rails['smtp_enable_starttls_auto'] = true ##修改gitlab配置的发信人 gitlab_rails['gitlab_email_from'] = "xxuser@163.com" user["git_user_email"] = "xxuser@163.com"