系统环境
操作系统:CentOS 7
GitLab:gitlab-ce-10.8.4-ce.0.el7.x86_64.rpm
下载Omnibus安装包
使用国内镜像加速下载地址
# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.8.4-ce.0.el7.x86_64.rpm
开始安装
1. 安装必要的依赖包
# yum install -y curl policycoreutils-python openssh-server
2. rpm安装
# rpm -ivh gitlab-ce-10.8.4-ce.0.el7.x86_64.rpm
rpm包默认安装在/opt/gitlab目录,运行目录为/var/opt/gitlab目录。
3. 修改配置文件
需要删除最前面的#才会生效
# vim /etc/gitlab/gitlab.rb
(1). 修改仓库git_data_dir存放位置
git_data_dirs({
"default" => {
"path" => "/data/gitlab/git-data"
}
})
(2). 修改数据库postgresql['data_dir']存放位置
postgresql['data_dir'] = "/data/gitlab/postgresql/data"
(3). 修改自带Nginx监听的端口
因为服务器上已经安装了Nginx,因此修改默认端口。
nginx['listen_port'] = 81
使配置生效并启动GitLab
第一次启动因为要初始化,等待的时间会比较长
# gitlab-ctl reconfigure
查看运行状态
# gitlab-ctl status
配置Nginx转发
在原来的Nginx中配置GitLab访问地址
server {
listen 80;
server_name localhost;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:81;
}
}
重启Nginx
# /web/nginx/sbin/nginx -s reload
汉化GitLab
1. 安装 git
安装依赖包
# yum install curl-devel perl-ExtUtils-MakeMaker perl
# wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
解压
# tar -xvf git-2.9.5.tar.gz
编译
# cd git-2.9.5
# ./configure && make && make install
# git --version
2. 下载汉化包并导出补丁
# git clone https://gitlab.com/xhang/gitlab.git
# cd gitlab
# git diff v10.8.0 v10.8.0-zh > ../v10.8.0-zh.diff
3. 安装补丁
停止GitLab服务
# gitlab-ctl stop
安装patch
# yum install patch
安装补丁,安装的时候可能会有文件找不到,忽略即可
# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < v10.8.0-zh.diff
启动GitLab服务
# gitlab-ctl start