1. 安装和配置必要的依赖项
在 CentOS 7(以及 RedHat/Oracle/Scientific Linux 7)上,下面的命令还将打开系统防火墙中的 HTTP、 HTTPS 和 SSH 访问
<span style="color:#444444">sudo yum install -y curl policycoreutils-python openssh-server perl
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</span>
下一步,安装后缀发送通知电子邮件。如果你想使用其他解决方案发送电子邮件,请跳过这一步,在 GitLab 安装之后配置一个外部 SMTP 服务器。
<span style="color:#444444">sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix</span>
设置postfix开机自启,并启动,postfix支持gitlab发信功能
systemctl enable postfix && systemctl start postfix
下载gitlab安装包,然后安装
centos 6系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6
centos 7系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
我的是centos7,所以我在https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7中找了个gitlab8.0.0版本,建议下载一个比较新的版本,我这里选了一个比较旧的版本仅仅是实验记录。
下载rpm包并安装:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
rpm -i gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
修改gitlab配置文件指定服务器ip和自定义端口
vi /etc/gitlab/gitlab.rb
退出并保存
ps:注意这里设置的端口不能被占用,默认是8080端口,如果8080已经使用,请自定义其它端口,并在防火墙设置开放相对应得端口。
重置并启动GitLab
执行以下命令
gitlab-ctl reconfigure
gitlab-ctl restart
ok: run: gitlab-git-http-server: (pid 3922) 1s
ok: run: logrotate: (pid 3929) 0s
ok: run: nginx: (pid 3936) 1s
ok: run: postgresql: (pid 3941) 0s
ok: run: redis: (pid 3950) 0s
ok: run: sidekiq: (pid 3955) 0s
ok: run: unicorn: (pid 3961) 1s
提示“ok: run:”表示启动成功。
查看防火墙开放端口的命令是
iptables-save
如果想增加对外开放的端口,就需要通过防火墙的管理命令firewalld-cmd,例如我想开放80端口,那么命令就是:
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
第一条命令是添加端口,第二条命令是重载防火墙。
看到sucess字样后,再使用iptables-save命令查看端口,可以看到,对外放开的端口增加了80.