小言_互联网的博客

Centos7 安装Gitlab详细步骤

491人阅读  评论(0)

先介绍卸载Gitlab

1. 查看是否安装gitlab
命令:rpm -qa | grep gitlab

2. 如果已经安装gitlab,就开始卸载
命令:rpm -e --nodeps gitlab-ce-*******l7.x86_64

3. 删除/opt/gitlab   和     /etc/gitlab

 如果后面要使用邮件先安装邮件依赖(一般不需要):

#安装所需依赖
yum install curl openssh-server openssh-clients postfix cronie
#GitLab使用postfix发送邮件 
service postfix start
#设置postfix开机自启动
chkconfig postfix on

gitlab 分为gitlab-ce和gitlab-ee,我们要安装ce社区版
gitlab-ce是社区版,免费的
gitlab-ee是企业版,收费的

 

一: 使用yum方式安装gitlab

1.配置yum源
命令: vim /etc/yum.repos.d/gitlab-ce.repo

2. 编辑yum源,粘贴以下脚本
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

保存下来

3. 更新本地缓存
命令:yum makecache


4. 安装gitlab (gitlab-ce后面可以指定版本号,若未指定安装最新版本)
命令:yum install gitlab-ce


5. 配置gitlab
命令:gitlab-ctl reconfigure
--  (这里可能出问题,解决方案在下面)


5. 重启gitlab
sudo gitlab-ctl restart

配置问题: 

gitlab配置文件修改
修改/etc/gitlab/gitlab.rb文件:


1. 基本配置
#外部访问url(冒号后面的为nginx端口号,默认为80,经过编译后,自动将这个配置编译到nginx配置,nginx配置文件为:/var/opt/gitlab/nginx/conf/gitlab-http.conf)
external_url 'http://www.test.com:8888'
#修改unicorn端口号,默认值就是8080,也可以不进行修改
unicorn['port'] = 9999


2. gitlab发送邮件配置(配置参考:https://docs.gitlab.com/omnibus/settings/smtp.html)
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxxx@xx.com"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com'
gitlab_rails['smtp_domain'] = "exmail.qq.com"


3. 如果你的ssh端口不是22号端口,需要修改:
gitlab_rails['gitlab_shell_ssh_port'] = 22


4. 配置生效
#先停止gitlab
sudo gitlab-ctl stop
#使配置生效
gitlab-ctl reconfigure
#重新启动GitLab,如果gitlab没有启动,使用gitlab-ctl start
gitlab-ctl restart
注意如果你修改了/var/opt/gitlab/nginx/conf/gitlab-http.conf文件的话,使用gitlab-ctl reconfigure命令的话,/var/opt/gitlab/nginx/conf/gitlab-http.conf文件信息会进行重置


3:测试是否安装成功
打开浏览器访问:www.test.com:8888或服务器ip:8888(例:192.168.11.201:8888),出现如下现象说明安装成功


如果出现拒绝访问,应该是防火墙问题,可以参考:linux之centos7防火墙基本使用
如果出现502报错,一般是由于端口号占用问题,更改端口号再重新使配置生效,重新访问

 

 在使用 gitlab-ctl reconfigure 命令后,可能出现的问题

1.  卸载后重新安装出现   ruby_block[supervise_redis_sleep] action run

在卸载gitlab然后再次安装执行sudo gitlab-ctl reconfigure的时候往往会出现:
ruby_block[supervise_redis_sleep] action run,会一直卡无法往下进行!

解决方案:

1、按住CTRL+C强制结束;

2、运行:sudo systemctl restart gitlab-runsvdir

3、再次执行:sudo gitlab-ctl reconfigure

2. 出现   bash[migrate gitlab-rails database]

Running handlers:
There was an error running gitlab-ctl reconfigure:

bash[migrate gitlab-rails database] (gitlab::database_migrations line 51) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash"  "/tmp/chef-script20190308-65247-12ck9rp" ----
STDOUT: rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
 Is the server running locally and accepting
 connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:52:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:db:configure
(See full trace by running task with --trace)
STDERR:
---- End output of "bash"  "/tmp/chef-script20190308-65247-12ck9rp" ----
Ran "bash"  "/tmp/chef-script20190308-65247-12ck9rp" returned 1



解决方案:
1. 停止gitlab
sudo gitlab-ctl stop
2. 修改sql权限
sudo chmod 755 /var/opt/gitlab/postgresql
3. 执行命令
sudo systemctl restart gitlab-runsvdir
4. 重新开始配置
sudo gitlab-ctl reconfigure

 


转载:https://blog.csdn.net/chuxin_mm/article/details/101289596
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场