centos 7 X86_64 安装gitlab-ce-15.9.3-ce.0.el7.x86_64
Gitlab-ce 首页:
https://packages.gitlab.com/gitlab/gitlab-ce/install#bash-rpm
https://about.gitlab.com/install/#centos-7
安装系统基础工具()
yum install epel-release -y
yum install htop nload iftop nethogs iotop git wget curl screen tree chrony -y
### 关闭selinux:
systemctl stop firewalld && systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
### 安装postfix:
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
****错误:
vim /etc/postfix/main.cf
#发现配置为:
inet_interfaces = localhost
inet_protocols = all
#改成:
inet_interfaces = all
inet_protocols = all
#重新启动就ok了
service postfix start
安装gitlab-ce 的yum源:
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
安装Gitlab-CE-15.9.3
yum install gitlab-ce-15.9.3 -y
# 修改配置文件:
vim /etc/gitlab/gitlab.rb
external_url 'http://gitlab.example.com'
改成
external_url 'http://192.168.3.130'
# 执行命令:
gitlab-ctl reconfigure
# 安装完成,提示密码存放路径:
用户名:root
密 码:/etc/gitlab/initial_root_password
该密码文件会在创建后24小时后删除
****************************************************************************
Running handlers:
[2023-03-11T23:27:32+08:00] INFO: Running report handlers
Running handlers complete
[2023-03-11T23:27:32+08:00] INFO: Report handlers complete
Infra Phase complete, 573/1542 resources updated in 03 minutes 13 seconds
Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.
NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
访问gitlab首页:
访问 http://192.168.3.130/ | root | CCCCCCCC
部分gitlab 命令:
# 命令:
gitlab-ctl status # 服务状态
gitlab-ctl restart # 重启服务
gitlab-ctl start # 启动服务
gitlab-ctl tail # 看日志
gitlab-ctl tail nginx # 查看日志
# 组件:
nginx # 静态web
gitlab-shell # 用于处理git命令和修改
gitlab-workhorse # 轻量级的反向代理服务器
logrotate # 日志文件管理工具
postgresql # 数据库
redis # 缓存数据库
unicorn gitlab rails # 应用是托管在这个服务器上面的
# 目录:
/var/opt/gitlab/git-data/repositories/root: # 库默认存储目录
/opt/gitlab: # 应用代码和相应的依赖程序
/var/opt/gitlab:gitlab-ctl reconfigure # 命令编译后的应用数据和配置文件,不需要认为修改配置
/etc/gilab: # 配置文件目录
/var/log/gitlab: # 此目录下存放了gitlab各个组件产生的日志
/var/opt/gilab/backups/: # 备份文件生成的目录
# 变更主配置文件:
gitlab-ctl reconfigure # 重置配置文件
gitlab-ctl show-config # 验证配置文件
gitlab-ctl restart # 重启gitlab服务
gitlab 后台中文
gitlab 后台切换中文显示
1.进入gitlab后台
点击右上角个人头像 -> settings -> profile -> Preferred language
2.默认选项是"English",选择"简体中文",然后点击下面绿色按钮"Update profile settings"
3.刷新页面
Gitlab 邮件设置:
配置邮箱服务的用途
有合并请求时,邮件通知
账号注册时,邮件验证
修改密码时,通过邮件修改
配置步骤:
.开启QQ邮箱的smtp服务(不建议使用163邮箱,发几次之后,就不能发送)
设置--》账户--》smtp--》密保验证--》验证成功返回一串字符串,形状如(sdfsdfasdfasd)
1 安装postfix:
之前已经安装并配置好可以启动起来.
2)配置gitlab.rb:
vim /etc/gitlab/gitlab.rb
gitlab_rails['smtp_enable'] = true # 启用 smtp 服务
gitlab_rails['smtp_address'] = "smtp.qq.com" # 配置 smtp 服务地址,这里需要填写邮件服务里面的“SMTP服务器地址”(如下是QQ邮箱的smtp服务器地址)
gitlab_rails['smtp_port'] = 465 # 配置 smtp 服务的端口号(默认)
gitlab_rails['smtp_user_name'] = "345345434@qq.com" # 配置发送邮件的电子邮箱名称(即刚才注册的邮箱名称)
gitlab_rails['smtp_password'] = "234234234sdfsd " # 配置发送邮件的电子邮箱授权密码,刚才在邮箱里面开启 SMTP 服务的时候弹框提示的那一串【授权密码】(切记:这里不是邮箱的登录密码,是SMTP的授权密码)
gitlab_rails['smtp_domain'] = "smtp.qq.com" # 配置 SMTP 服务的域名,和上面的smtp服务器地址一致(如下是网易163邮箱的smtp域名)
gitlab_rails['smtp_authentication'] = "login" # 配置 SMTP 鉴定类别(默认 login 即可)
gitlab_rails['smtp_enable_starttls_auto'] = true # 开启纯文本通信协议扩展
gitlab_rails['smtp_tls'] = true # 开启 smtp_tls (传输安全)
gitlab_rails['smtp_pool'] = false
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'xxxxxx@qq.com' # gitlab 服务邮件发送来源邮箱(即发出邮件的发送方邮箱),填写刚才注册的邮箱即可
gitlab_rails['gitlab_email_display_name'] = 'gitlab server' # gitlab 发送邮件显示的名字
3)重新加载配置信息
gitlab-ctl reconfigure
4) 重新启动服务
gitlab-ctl restart
5)测试邮件服务是否正常
gitlab-rails console
Notify.test_email('接收方邮件地址','邮件标题','邮件内容').deliver_now
按回车,测试发送。
[root@bj-hom-130 gitlab]# gitlab-rails console
--------------------------------------------------------------------------------
Ruby: ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-linux]
GitLab: 15.9.3 (f030ca96950) FOSS
GitLab Shell: 14.17.0
PostgreSQL: 13.8
------------------------------------------------------------[ booted in 26.00s ]
Loading production environment (Rails 6.1.7.2)
irb(main):001:0>
irb(main):002:0> Notify.test_email('sdfsdfsdf@qq.com','gitlab注册','测试邮件而已 gitlab').deliver_now
Delivered mail 640e9e27ebed9_105ae488012386@bj-hom-130.mail (1275.8ms)
=> #<Mail::Message:295840, Multipart: false, Headers: <Date: Mon, 13 Mar 2023 11:53:11 +0800>, <From: GitLab <sdfsdfsdfsdf@qq.com>>, <Reply-To: GitLab <noreply@192.168.3.130>>, <To: sdfsfsdfsfs@qq.com>, <Message-ID: <640e9e27ebed9_105ae488012386@bj-hom-130.mail>>, <Subject: gitlab注册>, <Mime-Version: 1.0>, <Content-Type: text/html; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>, <Auto-Submitted: auto-generated>, <X-Auto-Response-Suppress: All>>
irb(main):003:0>
如忘记管理员密码
gitlab-rails console //进入控制台
u=User.where(id:1).first //查找id为1的用户并赋值给u
u.password='new_password' //修改u的密码
u.password_confirmation='new_password' //确认密码信息
u.save! //保存用户信息
错误:
二 安装出现的问题
1. 安装时卡在ruby_block[wait for logrotate service socket]不动
原本已经安装一次gitlab , 然后卸载重装过程中出现该问题 ,
(1)首先按住CTRL+C强制结束正在安装的程序
(2)运行 sudo systemctl restart gitlab-runsvdir
执行完上述两步之后
gitlab-ctl reconfigure 重新启动程序
备注 : 如果在安装卡在wait for......地方不动,可以使用本方法试试能否解决