本人Linux是:Ubuntu18.04, kernel是:4.15.0-50-generic
根据此搭建gitlab服务器
安装相关依赖
- 安装远程登录的ssh,防火墙(firewalld),postfix(用于邮件通知) ,wget,以下这些命令也会打开系统防火墙中的HTTP和SSH端口访问
# apt -y install policycoreutils openssh-server postfix ca-certificates
- 将SSH服务设置成开机自启动,安装命令:
sudo systemctl enable sshd
- 启动SSH服务,安装命令:
sudo systemctl start sshd
- 安装防火墙(如果已经安装了防火墙并且已经在运行状态,则可直接进行后面步骤)
# apt install firewalld systemd -y
- 开启防火墙, 查询防火墙是否打开。
# systemctl enable firewalld.service
# systemctl start firewalld.service
# systemctl status firewalld.service
-
添加http服务到firewalld,pemmanent表示永久生效,若不加–permanent系统下次启动后就会失效。
# firewall-cmd --permanent --add-service=http
-
重启防火墙
# systemctl reload firewalld
下载gitlab安装软件
1.下载gitlab镜像
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/trusty/main/g/gitlab-ce/gitlab-ce_11.10.4-ce.0_amd64.deb
- 安装gitlab 安装命令:
# dpkg -i gitlab-ce_11.10.4-ce.0_amd64.deb
安装过程需要些时间,如果出现下图,则说明安装成功。
- 修改gitlab配置文件指定服务器ip和自定义端口:
# vim /etc/gitlab/gitlab.rb
初始值 | 修改后的值[格式:http://ip地址:端口] |
---|---|
external_url ‘http://gitlab.example.com’ | external_url ‘http://localhost:8000’ |
这样就可以通过localhost:8000端口访问gitlab了。