Gitlab有ee的企业收费版和ce的社区交流版(免费),打工人选择免费版
1、官网指南
Gitlab官网下载地址,点进去选择自己的系统,我这里选择centos7
然后往下滑一下,就有官网给出的安装步骤,这里只执行到第2步的第一条就可以了,看图
但中间还需要加几步,下面整理一下命令,含备注的部分为额外命令
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
# 在配置防火墙打开http等访问前,如果你不使用防火墙,那可以跳过
# 如果使用,先检查当前防火墙是否是运行状态
systemctl status firewalld
# 如果状态不是绿色的Active,启动防火墙
systemctl start firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
# 如果使用防火墙,就还需开放一个端口,用来访问gitlab,我添加为8888
firewall-cmd --permanent --zone=public --add-port=8888/tcp
systemctl restart firewalld
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
2、其他命令
走完上一步官网给出的步骤后,开始下载安装包,这里我使用的清华镜像站,并下载gitlab12版本,因为这个版本开始不需要安装汉化版,可以直接设置中文
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.0.8-ce.0.el7.x86_64.rpm
下载完成后使用rpm安装
rpm -i gitlab-ce-12.0.8-ce.0.el7.x86_64.rpm
出现下图即代表安装成功
3、修改配置
vim /etc/gitlab/gitlab.rb
在这里修改为你的外网IP:端口即可,这个端口与第一步防火墙开放的端口保持一致
然后执行下面两条命令,载入配置并重启,这两个过程都很慢,耐心等待
gitlab-ctl reconfigure
gitlab-ctl restart
4、访问与root账户配置
上一步最后全部OK就没问题了,访问IP:端口,第一次访问就会让你修改root管理员账户的初始密码,用户名为root,修改完就可以登录了
还有另外一种使用命令修改密码的方式:
执行下面的命令,进入控制台,这个进入的过程也很慢,耐心等待
sudo gitlab-rails console production
出现下图的样子即成功进入
然后,像操作数据库一样,拿到root用户的数据对象进行操作
u=User.where(id:1).first
u.password='设置你的密码'
u.save
最后一定要执行save,保存完就可以去登录了