安装并配置必要的依赖关系
首先要在CentOS系统上面安装所需的依赖:ssh、防火墙、postfix(用于邮件通知)、wegt,以下这些命令也会打开系统防火墙中的HTTP和SSH端口访问。
安装SSH协议
sudo yum install -y curl policycoreutils-python openssh-server
设置SSH服务开机自启动
sudo systemctl enable sshd
sudo systemctl start sshd
安装Postfix以发送邮件
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
添加GitLab镜像源并安装gitlab服务
添加gitlab镜像并安装
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.5.7-ce.0.el7.x86_64.rpm
rpm -i gitlab-ce-10.5.7-ce.0.el7.x86_64.rpm
修改gitlab配置
vi /etc/gitlab/gitlab.rb
# 访问地址
external_url 'http://192.168.31.163:8888'
# 端口必须相同
gitlab_workhorse['auth_backend'] = "http://localhost:6666"
unicorn['port'] = 6666
gitlab_rails['webhook_timeout'] = 90
防火墙开放端口
firewall-cmd --add-port=8888/tcp -permanent
firewall-cmd --add-port=6666/tcp -permanent
firewall-cmd --reload
更新配置并启动
# 刷新配置
gitlab-ctl reconfigure
# 服务启动及停止
gitlab-ctl start/stop/restart
# 查看日志
gitlab-ctl tail
# 查看状态
gitlab-ctl status
# 检查gitlab
gitlab-rake gitlab:check SANITIZE=true --trace
修改管理员密码
cd /opt/gitlab/bin
sudo gitlab-rails console production
# irb(main):001:0> 出现之后(User.all 查看所有用户)
u=User.where(id:1).first
u.password='admin@8888'
u.password_confirmation='admin@8888'
u.save!
注意
由于此处为centos虚拟机搭建(1G/1核/30G),网站响应速度有点慢,建议内存为2G,尤其当内存不够是会导致服务无法启动