[toc]
gitlab安装
rpm包安装
安装依赖包
# 安装依赖包
yum -y install curl openssh-server openssh-clients postfix cronie policycoreutils-python
# 启动postfix
systemctl start postfix && systemctl enable postfix
下载安装包
也可以从 清华源 下载
export VERSION=17.4.0
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-${VERSION}-ce.0.el7.x86_64.rpm/download.rpm
安装
说明
如需卸载可以参考 官方文档
yum -y localinstall gitlab-ce-${VERSION}-ce.0.el7.x86_64.rpm
修改配置文件
说明
修改 /etc/gitlab/gitlab.rb 中 xternal_url 一行,修改为自己的域名或IP
export DOMAIN=10.0.0.100
sed -i.bak "/^external_url/c external_url 'http://$DOMAIN'" /etc/gitlab/gitlab.rb
启动gitlab
# 启动gitlab
gitlab-ctl start
# 重载gitlab配置文件
gitlab-ctl reconfigure
# 设置gitlab开机自启
systemctl enable gitlab-runsvdir.service
重载配置文件成功提示如下
低版本

高版本

gitlab启动的端口
$ netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 3276/sidekiq 5.2.9
tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 3770/gitaly
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 969/sshd
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN 3926/grafana-server
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1194/master
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 3330/nginx: master
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 3815/redis_exporter
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 3897/prometheus
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 3919/postgres_expor
tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 3911/alertmanager
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 3791/node_exporter
tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 3778/gitlab-workhor
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 701/rpcbind
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 3802/ruby
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 3253/puma 5.1.1 (un
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3330/nginx: master
tcp6 0 0 :::22 :::* LISTEN 969/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1194/master
tcp6 0 0 :::9094 :::* LISTEN 3911/alertmanager
tcp6 0 0 :::111 :::* LISTEN 701/rpcbind
tcp6 0 0 ::1:9168 :::* LISTEN 3802/ruby
yum安装
安装并配置必要的依赖项
安装依赖包
yum -y install curl policycoreutils-python openssh-server perl
安装 Postfix(或 Sendmail)来发送通知邮件。如果您想使用其他解决方案发送电子邮件,请跳过此步骤
yum -y install postfix
systemctl enable postfix
systemctl start postfix
添加官方yum源
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
安装
说明
# 默认安装最新版
sudo EXTERNAL_URL="https://gitlab.example.com" yum -y install gitlab-ce
# 安装指定版本
sudo EXTERNAL_URL="https://gitlab.example.com" yum -y install gitlab-ce-13.12.3
gitlab启动的端口
$ netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 3581/gitaly
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1254/sshd
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN 3671/grafana-server
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1181/master
tcp 0 0 0.0.0.0:5050 0.0.0.0:* LISTEN 3098/nginx: master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 3098/nginx: master
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 3098/nginx: master
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 3636/redis_exporter
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 3641/prometheus
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 3665/postgres_expor
tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 3658/alertmanager
tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 3599/registry
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 3629/node_exporter
tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 3587/gitlab-workhor
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 588/rpcbind
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 3634/ruby
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 2922/puma 5.1.1 (un
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3098/nginx: master
tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 2943/sidekiq 5.2.9
tcp6 0 0 :::22 :::* LISTEN 1254/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1181/master
tcp6 0 0 :::9094 :::* LISTEN 3658/alertmanager
tcp6 0 0 :::111 :::* LISTEN 588/rpcbind
tcp6 0 0 ::1:9168 :::* LISTEN 3634/ruby
关闭https自动重定向
说明
使用gitlab-ce官方提供的脚本安装后,gitlab-ce会默认开启 http->https 重定向,如果使用nginx做代理则需要关闭https自动重定向
编辑 /etc/gitlab/gitlab.rb 文件,取消以下行的注释
nginx['redirect_http_to_https'] = false
重载配置文件
gitlab-ctl reconfigure