CentOS7上搭建gitlab服务器

CentOS7上搭建gitlab服务器

本文主要参考了官方文档https://www.gitlab.com.cn/installation/#centos-7,重点是记录安装过程中遇到问题的解决办法。

根据官方文档,依此执行如下命令即可:

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://192.168.1.64:8080" yum install -y gitlab-ee
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

现在就可以在浏览器中访问http://192.168.1.64:8080了。

  • 问题1:访问无响应

解决办法:防火墙中添加8080/tcp例外,命令如下:

sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
  • 问题2:访问返回502错误

原因及解决办法:8080端口已被tomcat占用,因此需要修改端口。打开配置文件sudo vim /etc/gitlab/gitlab.rb,修改如下配置:

external_url 'http://192.168.1.64:8070'
unicorn['port'] = 8090
nginx['listen_port'] = 8070

同时防火墙添加8070/tcp和8090/tcp例外:

sudo firewall-cmd --permanent --add-port=8070/tcp
sudo firewall-cmd --permanent --add-port=8090/tcp
sudo firewall-cmd --reload

最后重启:

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

如果不放心,可以查看nginx的配置,看监听的端口是否为8070,服务器名称是否为192.168.1.64。如下:

sudo vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
server {
  listen *:8070;

  server_name 192.168.1.64;

好了,现在访问http://192.168.1.64:8070就没有问题了。第一次访问首先弹出的是设置root用户的密码,设置完成后用root用户及刚设置的密码登录即可。

posted @ 2019-01-07 11:20  鸟瞰的鸟  阅读(217)  评论(0编辑  收藏  举报