CentOS搭建Gitlab的详细教程

前期准备

  1. 服务器:CentOS7
  2. 安装文件:gitlab-ce-12.6.3-ce.0.el7.x86_64.rpm

安装gitlab

介绍一下两种安装方式 yum安装、rmp安装(个人喜欢第二种方式,有时候yum下载的有点慢)。

yum安装

这里直接参考官网安装教程

gitlab安装教程

gitlab安装教程

打开linux系统终端,首先安装gitlab必须的ssh,以及在系统防火墙中打开HTTP、HTTPS和SSH访问。

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 firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld

然后是安装发送邮件功能的postfix

sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

添加gitlab的包仓库(ee改成ce)

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

安装gitlab(EXTERNAL_URL指的是你的gitlab访问地址,这里改为http://+你的linux系统ip)

sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ce

rpm安装

使用官网的安装方式下载很慢(亲测网上的阿里站点,清华站点也不是很快),这里教大家直接下载rmp安装包手动安装。

首先去官网安装包仓库下载我们所需的安装包版本

官网安装包仓库

官网安装包仓库

下载完成之后将文件拷贝至你的linux服务器,同样需要配置ssh、防火墙、postfix,

# 安装gitlab必须的ssh,以及在系统防火墙中打开HTTP、HTTPS和SSH访问。
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 firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
# 安装发送邮件功能的postfix
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

然后cd进入你的安装包路径进行安装

# 安装 example.rpm 包并在安装过程中显示正在安装的文件信息及安装进度
rpm -ivh example.rpm 

出现下图即为安装成功

安装成功图

安装成功图

这种方式需要我们手动进入配置文件中修改访问地址

sudo vim /etc/gitlab/gitlab.rb

# 修改文件中external_url 'http://你linux的ip'

并且我们还需要修改默认的gitlab clone地址,要不每次都得自己修改

gitlab仓库

gitlab仓库

修改文件配置

sudo vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

将图片上标红处的Host替换成你的域名或ip

替换IP

替换IP

访问

重置并启动GitLab,执行以下命令

gitlab-ctl reconfigure

gitlab-ctl restart

提示 “ok: run:”表示启动成功

run

run

然后浏览器上输入你的访问地址(第一次访问会让你输入新密码,用户名默认为root)

gitlab登录页

gitlab登录页

安装过程中遇到的问题

  1. 在浏览器中访问GitLab出现502错误:
    原因:内存不足。
    解决办法:检查系统的虚拟内存是否随机启动了,如果系统无虚拟内存,则增加虚拟内存,再重新启动系统。
  2. 8080端口冲突:
    原因:由于unicorn默认使用的是 8080 端口。
    解决办法:打开 /etc/gitlab/gitlab.rb ,打开 # unicorn['port'] = 8080 的注释,将 8080 修改为 9999 ,保存后运行 sudo gitlab-ctl reconfigure 即可。
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
CentOS 7.9搭建GitLab服务器的步骤如下: 1. 更新系统:首先,使用命令“sudo yum update”来更新系统软件包。 2. 安装必要的依赖:执行以下命令安装Git和其他必要的依赖项: ``` sudo yum install curl policycoreutils openssh-server openssh-clients perl sudo systemctl enable sshd sudo systemctl start sshd sudo firewall-cmd --permanent --add-service=http sudo systemctl reload firewalld ``` 3. 添加GitLab软件源:使用以下命令添加GitLab的官方软件源: ``` curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash ``` 4. 安装GitLab:运行以下命令安装GitLab Community Edition(CE)或Enterprise Edition(EE): - 安装GitLab CE: ``` sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce ``` - 安装GitLab EE(需要许可证): ``` sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee ``` 这里将`http://gitlab.example.com`替换为您的服务器的公共IP地址或域名。 5. 配置GitLab:编辑GitLab配置文件`/etc/gitlab/gitlab.rb`,根据需要设置外部URL和其他配置参数。例如,要使用HTTPS,可以取消注释并设置相应的证书和密钥路径。 6. 重新配置GitLab:运行以下命令重新配置GitLab: ``` sudo gitlab-ctl reconfigure ``` 7. 启动GitLab:执行以下命令启动GitLab: ``` sudo gitlab-ctl start ``` 8. 访问GitLab:使用浏览器访问服务器的公共IP地址或域名,在地址栏中输入之前设置的外部URL。 通过完成上述步骤,您应该能够在CentOS 7.9上成功搭建GitLab服务器。根据需要,您还可以配置其他功能,如用户管理、项目管理、权限设置等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dylan、

耕码不易,白嫖可耻

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值