centos

GitLab在CentOS上的配置步骤是什么

小樊
45
2025-03-21 14:44:43
栏目: 智能运维
Centos服务器限时活动,0元免费领! 查看>>

在CentOS上配置GitLab涉及多个步骤,包括安装必要的软件包、配置网络设置、设置邮件服务、安装GitLab软件包以及修改配置文件等。以下是详细的步骤:

安装依赖包

首先,更新系统并安装必要的依赖包:

sudo yum update -y
sudo yum install -y curl policycoreutils-python openssh-server postfix wget vim

配置网络

配置防火墙以允许HTTP和HTTPS流量:

sudo yum install firewalld -y
sudo systemctl enable firewalld
sudo systemctl start firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

配置邮件服务

安装并配置Postfix邮件服务器以发送GitLab通知邮件:

sudo yum install postfix -y
sudo systemctl enable postfix
sudo systemctl start postfix

/etc/gitlab/gitlab.rb文件中配置邮件服务,例如使用QQ邮箱:

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "your_email@example.com"
gitlab_rails['smtp_password'] = "your_password"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = 'your_email@example.com'
gitlab_rails['smtp_domain'] = "example.com"

执行gitlab-ctl reconfigure使配置生效:

sudo gitlab-ctl reconfigure

安装GitLab

添加GitLab的RPM镜像源并安装GitLab软件包:

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-17.3.1-ce.0.el7.x86_64.rpm
sudo rpm -i gitlab-ce-17.3.1-ce.0.el7.x86_64.rpm

配置GitLab

修改GitLab的配置文件/etc/gitlab/gitlab.rb,设置外部URL和其他配置项:

sudo vim /etc/gitlab/gitlab.rb

例如,设置外部URL为http://your_server_ip:8080,并保存退出。

执行gitlab-ctl reconfigure使配置生效:

sudo gitlab-ctl reconfigure

启动GitLab

启动GitLab服务并设置为开机自启动:

sudo gitlab-ctl start
sudo systemctl enable gitlab-ce

访问GitLab

完成上述步骤后,通过指定的服务器IP地址和端口号访问GitLab界面。初次登录时,使用预设的初始账户名(root)和默认密码(5iveL!fe),首次登录后系统会要求您更改密码。

请注意,以上步骤可能会随着GitLab版本的更新而有所变化,建议参考GitLab的官方文档或最新的安装指南进行操作。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

相关推荐:GitLab在CentOS上的配置步骤

0
看了该问题的人还看了