在centos系统上部署gitlab,本文提供详细步骤及问题排查方法。
准备工作
-
系统更新: 确保centos系统已更新到最新版本:
sudo yum update
-
依赖安装: 安装必要的软件包:
-
SSH服务启用: 设置SSH服务开机自启动:
sudo systemctl enable sshd sudo systemctl start sshd
-
防火墙配置: 允许http、https和SSH流量通过防火墙:
sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --permanent --add-service=ssh sudo firewall-cmd --reload
-
gitLab YUM源添加: 添加gitlab官方YUM源:
sudo curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
GitLab安装与配置
-
GitLab安装: 使用yum安装GitLab社区版:
sudo yum install gitlab-ce
-
配置文件修改: 编辑/etc/gitlab/gitlab.rb文件,设置external_url为你的服务器IP地址和端口(例如http://your_server_ip:port)。 保存并退出。
-
GitLab重新配置和启动:
sudo gitlab-ctl reconfigure sudo gitlab-ctl restart
常见问题解决
-
端口冲突: 如果出现端口占用错误(Address already in use),使用以下命令查找并终止占用进程:
lsof -i :port # 将port替换为冲突的端口号 kill -9 pid # 将pid替换为进程ID
-
防火墙问题: 再次检查防火墙设置,确保已开启HTTP (80), HTTPS (443) 和 SSH (22) 端口。
-
SELinux: 如果启用SELinux,可能需要临时禁用(注意安全风险):
sudo setenforce 0 sudo sed -i 's/SELinux=enforcing/SELINUX=disabled/g' /etc/selinux/config
安装完成后,建议重新启用SELinux。
完成以上步骤后,GitLab应该已成功安装并配置。 如有任何问题,请参考GitLab官方文档。