最近公司的服务器坏了需要重新搭建gitlab,新买的服务器安装的系统为CentOS7,下面是本人安装的过程记录一下。
1.安装ssh:
sudo yum install -y curl policycoreutils-pythonopenssh-server
第一步就报错了:
CentOS报错:Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock32 error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
百度发现是安装系统时没有配置DNS的问题,配置完DNS执行正常(配置DNS自行百度)
2.将SSH服务设置成开机自启动,安装命令:
sudo systemctl enable sshd
3.启动SSH服务,安装命令:
sudo systemctl start sshd
4.安装防火墙:
yum install firewalld systemd -y
5.开启防火墙,安装命令:
service firewalld start
6.添加http服务到firewalld,pemmanent表示永久生效,若不加--permanent系统下次启动后就会失效。
sudo firewall-cmd --permanent --add-service=http
7.重启防火墙,安装命令:
sudo systemctl reload firewalld
8.接下来,安装Postfix以发送通知邮件,安装命令:
sudo yum install postfix
9.将postfix服务设置成开机自启动,安装命令:
sudo systemctl enable postfix
10.启动postfix,安装命令:
sudo systemctl start postfix
11.wget 用于从外网上下载插件,安装wget:
yum -y install wget
12.安装vim编辑器 安装命令:
yum install vim -y
前面12步是安装gitlab的前提准备,接下来安装gitlab,接下来会有不少坑
13.添加gitlab镜像:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
14.安装gitlab命令:
rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
如果发生下面错误:
warning: soft/gitlab-ce-10.7.3-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
error: Failed dependencies:
policycoreutils-python is needed by gitlab-ce-10.7.3-ce.0.el7.x86_64
根据提示安装 policycoreutils-python
yum install policycoreutils-python
然后再执行安装gitlab的命令:
rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
安装过程需要些时间,如果出现下图,则说明安装成功。
15.修改gitlab配置文件指定服务器ip和自定义端口:
vim /etc/gitlab/gitlab.rb
将external_url 'http://localhost' ====》external_url 'http://ip:prot'
16.加载gitlab配置文件:
gitlab-ctl reconfigure
17.启动gitlab:
gitlab-ctl restart
18.访问 GitLab页面,初始账户: root 密码:5iveL!fe,但是登录不进去,原因是没有关闭防火墙
19.关闭防火墙
暂时关闭防火墙
systemctl stop firewalld
永久关闭防火墙
systemctl disable firewalld
到这里就可以访问到gitlab页面了。
GitLab 部署及管理员账号初始化(参考: )
获取/修改超级管理员root的密码
a、 切换目录:cd /opt/gitlab/bin
b、执行 :sudo gitlab-rails console production 命令 开始初始化密码
c、在irb(main):001:0> 后面通过 u=User.where(id:1).first 来查找与切换账号(User.all 可以查看所有用户)
d、通过u.password='12345678'设置密码为12345678(这里的密码看自己喜欢):
e、通过u.password_confirmation='12345678' 再次确认密码
f、通过 u.save!进行保存(切记切记 后面的 !)
g、如果看到上面截图中的true ,恭喜你已经成功了,执行 exit 退出当前设置流程即可。
h、回到gitlab ,可以通过 root/12345678 这一超级管理员账号登录了