gitlab 搭建(基于现有nginx)

普通搭建请看:gitlab 搭建

一.gitlab搭建

1.添加GitLab镜像源并安装gitlab服务器

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm

2.安装gitlab 安装命令:安装过程需要些时间

rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm

 3.修改gitlab配置文件指定服务器ip和自定义端口:

vim  /etc/gitlab/gitlab.rb
external_url 'http://localhost:8099'
nginx['enable'] = false
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8098"  //这个端口号一会和Nginx代理的端口号要一致

4.汉化gitlab

安装git

yum install -y git

克隆获取汉化版本库

项目地址为:https://gitlab.com/xhang/gitlab
我的gitlab版本为10.5.1
git clone https://gitlab.com/xhang/gitlab.git -b v10.0.0-zh
想要其他版本的gitlab:
git clone https://gitlab.com/xhang/gitlab.git -b vX.X.X-zh即可

停止gitlab服务

gitlab-ctl stop

进入git下载的gitlab项目

cd gitlab 

比较汉化标签和原标签,导出 patch 用的 diff 文件到/root下 

git diff v10.0.0 v10.0.0-zh > ../10.0.0-zh.diff

回到/root目录

cd 

将10.0.0-zh.diff作为补丁更新到gitlab中 

patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < 10.0.0-zh.diff

启动gitlab

gitlab-ctl reconfigure
gitlab-ctl start

二、nginx配置

vi /etc/nginx/conf/vhost/gitlab-http.conf
server {
    listen       8099;  #我的gitlab一般使用8099端口访问
    server_name  localhost;

    location / {
        root  html;
        index index.html index.htm;
        proxy_pass http://127.0.0.1:8098; #这里与前面设置过的端口一致
    }
}
重启nginx
systemctl restart nginx
开机自启动gitlab
systemctl enable gitlab-runsvdir

输入地址:192.168.233.135:8099访问gitlab
进入后会提示添加密码
默认账号:root 或admin@example.com

参考:gitlab自带的Nginx与原Nginx冲突的解决方案
原文地址:https://www.cnblogs.com/l-zl/p/13820780.html