1、配置yum源
复制以下内容:
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
插入到此文件中:
vim /etc/yum.repos.d/gitlab-ce.repo
2、更新本地yum缓存
sudo yum makecache
3、安装GitLab社区版
sudo yum install gitlab-ce #自动安装最新版
sudo yum install gitlab-ce-x.x.x #安装指定版本
4、安装依赖包。
sudo yum install -y curl policycoreutils-python openssh-server
5、设置SSH开机自启动并启动SSH服务。
sudo systemctl enable sshd
sudo systemctl start sshd
6、在防火墙上永久允许HTTP,并重启防火墙
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
7、遇到的问题
7.1、Gitlab访问拒绝
防火墙没有打开,连接失败;nginx的域名server_server参数缺失。
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
7.2、Gitlab页面502
nginx及unicorn端口被占用导致访问失败,出现404或502问题
修改unicorn端口
1.修改/etc/gitlab/gitlab.rb
默认端口为8080,可能被使用,修改为8200
2.修改/var/opt/gitlab/gitlab-rails/etc/unicorn.rb
sudo gitlab-ctl reconfigure
gitlab-ctl restart
7.3、Gitlab默认配置
1、默认80接口,如果修改接口,每次执行启动命令之后gitlab-ctl reconfigure
会初始化配置文件,需要重新修改端口号。
2、Gitlab关联服务环境较多,启动较慢,在启动过程中访问会报502错误,等一会就好了
8、启动服务
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start
9、GitLab常用命令
sudo gitlab-ctl start # 启动所有 gitlab 组件;
sudo gitlab-ctl stop # 停止所有 gitlab 组件;
sudo gitlab-ctl restart # 重启所有 gitlab 组件;
sudo gitlab-ctl status # 查看服务状态;
sudo gitlab-ctl reconfigure # 启动服务;
sudo vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
sudo gitlab-ctl tail # 查看日志;