centos7安装 gitlab-ce-14.7.7
安装前准备
安装 SSH
sudo yum install -y curl policycoreutils-pythonopenssh-server
yum -y install policycoreutils openssh-serve openssh-clients postfix
安装Postfix以发送通知邮件
#安装命令:
sudo yum install postfix
#将postfix服务设置成开机自启动,安装命令:
sudo systemctl enable postfix
#启动postfix,安装命令:
sudo systemctl start postfix
安装policycoreutils-python
yum install policycoreutils-python
gitlab 安装配置
下载
下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/?C=M&O=D
安装
rpm -i gitlab-ce-14.7.7-ce.0.el7.x86_64.rpm
出现该图标表示安装成功
配置ip与端口
vim /etc/gitlab/gitlab.rb
# 配置如下
external_url 'http://localhost:8089'
修改自带的nginx配置
自带Nginx 默认80 端口,如不冲突也可不修改
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
重置并启动GitLab
- 生效配置 时间相对较久
# gitlab-ctl reconfigure
# gitlab-ctl restart
如果开启了防火墙需要开放端口
firewall-cmd --zone=public --add-port=8089/tcp --permanent
firewall-cmd --reload
访问 gitlab
用户密码说明
/etc/gitlab/initial_root_password
登陆
我这里没有修改Nginx 端口,所有默认80 http://192.168.56.8
密码修改
修改服务端密码
首次登陆需修改密码
修改客户端密码
首先root登录linux服务器
gitlab-rails console -e production
user = User.where(id: 1).first
user.password = 'password'
user.password_confirmation = 'password'
user.save!
exit
完整操作如下:
[root@wyf-node1 var]# gitlab-rails console -e production
--------------------------------------------------------------------------------
Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
GitLab: 14.7.7 (10669ffeb75) FOSS
GitLab Shell: 13.22.2
PostgreSQL: 12.7
--------------------------------------------------------------------------------
Loading production environment (Rails 6.1.4.4)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password = 'password'
=> "password"
irb(main):003:0> user.password_confirmation = 'password'
=> "password"
irb(main):004:0> user.save!
=> true
irb(main):005:0> exit
常用命令
- 关闭
# gitlab-ctl stop
- 开启
# gitlab-ctl start
- 查看状态
# gitlab-ctl status
异常
本地git clone 项目时遇到 port:xxxx:Connection refused
解决:
修改 cd /opt/gitlab/embedded/service/gitlab-rails/config下的 gitlab.yml中的host和port 为你自己的
[root@wyf-node1 var]# cd /opt/gitlab/embedded/service/gitlab-rails/config
[root@wyf-node1 config]# vi gitlab.yml
[root@wyf-node1 config]# gitlab-ctl restart
ok: run: alertmanager: (pid 6697) 1s
ok: run: gitaly: (pid 6712) 0s
ok: run: gitlab-exporter: (pid 6730) 1s
ok: run: gitlab-workhorse: (pid 6732) 0s
ok: run: grafana: (pid 6741) 0s
ok: run: logrotate: (pid 6754) 1s
ok: run: nginx: (pid 6764) 0s
ok: run: node-exporter: (pid 6777) 1s
ok: run: postgres-exporter: (pid 6783) 0s
ok: run: postgresql: (pid 6792) 1s
ok: run: prometheus: (pid 6877) 0s
ok: run: puma: (pid 6893) 0s
ok: run: redis: (pid 6898) 0s
ok: run: redis-exporter: (pid 6904) 1s
ok: run: sidekiq: (pid 6914) 0s
[root@wyf-node1 config]#
原因
- 原因在gitlab.rb中配置一nginx的监听端口,所以在执行gitlab-ctl reconfigure后,gitlab.yml默认的端口还是80,所以修改如下,修改完成后,重启就好了gitlab-ctl restart
- 只要执行gitlab-ctl reconfigure后都需要检查端口是否被覆盖
重启完成后,项目的http clone方式会带上指定的端口
|