centOS7安装gitlab-ce
安装和配置必要的依赖项
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
接下来,安装Postfix以发送通知电子邮件。如果要使用其他解决方案发送电子邮件,请跳过此步骤并 在安装GitLab之后配置外部SMTP服务器。
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
使用官网添加GitLab软件包存储库,存在问题,我们使用清华大学开源软件镜像站
新建/etc/yum.repos.d/gitlab-ce.repo,内容为
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
再执行
sudo yum makecache
sudo yum install gitlab-ce
配置gitlab
配置文件位置/etc/gitlab/gitlab.rb
external_url 'http://127.0.0.1' # 这里一定要加上http://
#unicorn['port'] = 8080
puma['port'] = 8080
nginx['listen_port'] = 80
修改好配置文件后,要使用 gitlab-ctl reconfigure 命令重载一下配置文件,否则不生效。
gitlab-ctl reconfigure # 重载配置文件
gitlab常用命令
gitlab-ctl start # 启动所有 gitlab 组件
gitlab-ctl stop # 停止所有 gitlab 组件
gitlab-ctl restart # 重启所有 gitlab 组件
gitlab-ctl status # 查看服务状态
gitlab-ctl reconfigure # 启动服务
gitlab-ctl show-config # 验证配置文件
gitlab-ctl tail # 查看日志
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab
vi /etc/gitlab/gitlab.rb # 修改默认的配置文件
重置管理员账号密码
通过xshell连接到gitlab安装的服务器
进入gitlab控制台
输入gitlab-rails console进入gitlab控制台,只有进入到控制台之后,才可以输入gitlab的查询语句,才会被解析
gitlab-rails console
查询gitlab超级管理员信息
输入user = User.where(id:1).first查询id为1的用户对象,因为超级管理员用户默认都是1,也可以更加username来查询用户对象,管理员账户对象查询到之后,可以从返回的信息中看到admin为true,username为root
irb(main):001:0> user = User.where(id:1).first
=> #<User id:1 @root>
重置密码
输入user.password='密码',密码位置填写您新的密码即可。然后再输入user.save!保存用户对象
irb(main):002:0> user.password='新密码'
=> "新密码"
irb(main):003:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: a87b7fd0-7fa7-4744-b46d-5223d4d3f8b5) to Sidekiq(mailers) with arguments: "DeviseMailer", "://gitlab/User/1
=> true
正文到此结束