一、查看GitLab的官方网站
GitLab的官方网站找到对应系统安装gitlab的介绍页面如下:
https://about.gitlab.com/install/#centos-6
二、安装必要的依赖
- 1、在CentOS 6(和RedHat / Oracle / Scientific Linux 6)上,以下命令还将在系统防火墙中打开HTTP和SSH访问
sudo yum install -y curl policycoreutils-python openssh-server cronie
sudo lokkit -s http -s ssh
- 2、接下来,安装Postfix以发送通知电子邮件。如果要使用其他解决方案发送电子邮件,请跳过此步骤并在安装GitLab后配置外部SMTP服务器
sudo yum install postfix
sudo service postfix start
sudo chkconfig postfix on
在Postfix安装期间,可能会出现配置屏幕。选择“Internet Site”并按Enter键。使用服务器的外部DNS作为“邮件名称”,然后按Enter键。如果出现其他屏幕,请继续按Enter键接受默认值
- 3、添加GitLab软件包存储库并安装软件包(ce为社区版)
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo yum install gitlab-ce
该安装下载非常慢,可以修改为国内镜像
- 4、Gitlab国内镜像下载安装
官方地址:https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
1、新建 /etc/yum.repos.d/gitlab-ce.repo,内容为
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
2、再执行下面命令即可
sudo yum makecache
sudo yum install gitlab-ce
- 5、修改配置
修改/etc/gitlab/gitlab.rb文件
修改exrernal_url:改成机器域名或者IP地址
external_url 'http://192.168.137.130'
修改 unicorn 端口
# unicorn['listen'] = 'localhost'
# unicorn['port'] = 8080
unicorn['port'] = 8090
修改nginx端口
# nginx['listen_port'] = nil
nginx['listen_port'] = 8089
修改完配置后需要重启
gitlab-ctl reconfigure
通过访问http://192.168.137.130:8089即可访问后台管理页面
过程中可能会报错"GitLab Error: Error executing action
create
on resource 'group[gitlab-www]'" 需要修改username
将配置文件中username改为"gitlab"
user['username'] = "gitlab"
user['group'] = "gitlab"
网友评论