gitlab服务器搭建(CentOS)

CentOS安装必要的依赖(前期工作)

gitlab 安装包离线下载地址
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/

  1. 安装ssh

sudo yum install -y curl policycoreutils-pythonopenssh-server

  1. 将SSH服务设置成开机自启动并启动SSH服务

sudo systemctl enable sshd

sudo systemctl start sshd

  1. 安装并启动防火墙(如已安装可跳过)

yum install firewalld systemd -y

service firewalld start

  1. 添加http服务到firewalld (--permanent表示永久生效);

firewall-cmd --permanent --add-service=http

  1. 重启防火墙;

systemctl reload firewalld

  1. 将postfix服务设置成开机自启动并启动postfix(邮件服务);

systemctl enable postfix

systemctl start postfix

  1. 检查系统中是否已经安装wget(若不存在,用yum安装wget);

wget -V --检查wget版本

yum -y install wget --yum安装wget

安装gitlab

  1. wget下载gitlab(社区版);

下载地址为:
https://packages.gitlab.com/gitlab/gitlab-ce

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm(地址换成自己下载的最新版本)

  1. 安装gitlab;

rpm -ivh gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm

若出现下面错误,需要安装 policycoreutils-python;

yum -y install policycoreutils-python

image
  1. 修改gitlab配置文件,指定服务器ip和自定义端口;

vim /etc/gitlab/gitlab.rb

修改URL:external_url 'http://172.20.46.127:1213'

修改下面的端口号防止502错误:Whoops, GitLab is taking too much time to respond.

修改端口:nginx['listen_port'] = 1213

要修改unicorn的配置:

unicorn['listen'] = 'localhost'

unicorn['port'] = '1213'

  1. 重置并启动GitLab;

重置配置:gitlab-ctl reconfigure

重启gitlab服务:gitlab-ctl restart

  1. 访问Gitlab,初次登录,修改密码;

初始用户:root

安装启动成功: 连接超时处理方法:

  1. window下 使用 telnet ip port 查看端口是否开放

  2. 如果没开放端口,则在gitlab服务器开放端口

附注 liunx 防火墙操作

查看80端口是否开启

firewall-cmd --query-port=80/tcp

开启80端口

firewall-cmd --add-port=80/tcp --permanent # --permanent 永久生效,没有此参数重启后失效

关闭80端口

firewall-cmd --remove-port=80/tcp --permanent # --permanent 永久生效,没有此参数重启后失效

重启防火墙
systemctl reload firewalld

你可能感兴趣的:(gitlab服务器搭建(CentOS))