1.服务器配置
由于运行gitlab需要1.5G内存,因此最低配置:CPU:2核(至少),内存:4G
2.防火墙配置
# 查看状态
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# systemctl status firewalld
# 停止
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# systemctl disable firewalld
# 禁用
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# systemctl stop firewalld
3.安装GitLab依赖包
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# yum install -y curl policycoreutils-python openssh-server postfix
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# systemctl enable postfix
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# systemctl start postfix
启动postfix时会遇到以下错误:
/usr/sbin/postconf: fatal: parameter inet_interfaces: no local interface found for ::1
解决方法:
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# vi /etc/postfix/main.cf
# 将以下 localhost 改为 all
# inet_interfaces = localhost
inet_interfaces = all
inet_protocols = all
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# systemctl start postfix
4.下载rpm包到本地
# 使用清华大学的镜像,可以进入 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7 查看最新版本
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.8.1-ce.0.el7.x86_64.rpm
5.安装 GitLab RPM包
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# rpm -i gitlab-ce-12.8.1-ce.0.el7.x86_64.rpm
6.配置自定义GitLab端口(非常重要!!!)
由于阿里云每个自定义端口都需要在安全组配置,否则将会出现不能访问的问题!
7.修改端口
# 先备份 gitlab.rb
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# vi /etc/gitlab/gitlab.rb
...
nginx['listen_port'] = 83
unicorn['port'] = 8083
nginx['redirect_http_to_https_port'] = 83
...
# 先备份 gitlab-http.conf
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# cp /var/opt/gitlab/nginx/conf/gitlab-http.conf /var/opt/gitlab/nginx/conf/gitlab-http.conf.bak
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# vi [root@iZ8vb2zp3hb2pskrfnjcrbZ ~]#
...
server {
listen *:83;
}
# 先备份
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# cp /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /var/opt/gitlab/gitlab-rails/etc/unicorn.rb.bak
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# vi /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
# 修改端口
listen “127.0.0.1:8083”, :tcp_nopush => true
# 保存配置
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# gitlab-ctl reconfigure
# 重启
[root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# gitlab-ctl restart
8.重启验证
重启后,在浏览器输入 http://域名:83 或者 http://IP地址:83
9.GitLab相关事项
-
第一次登录时提示输入root密码,默认是root用户名;
-
Configure GitLab -> Settings 去掉注册功能:
去掉勾选 Sign-up enabled
-
root用户名称修改成一个比较复杂的名称
-
添加外部用户时,勾选 External 设置成外部人员。