其他分享
首页 > 其他分享> > 安装gitlab

安装gitlab

作者:互联网

2.1 方式一:下载gitlab-ce的rpm包

将对应版本的gitlab-ce下载到本地后,直接yum安装即可

 
# 要先将这个rpm包下载到本地
yum install -y gitlab-ce-13.6.1-ce.0.el7.x86_64.rpm

2.2 方式二:配置yum源

在 /etc/yum.repos.d/ 下新建 gitlab-ce.repo,写入如下内容:

 
[gitlab-ce]
name=gitlab-ce
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
Repo_gpgcheck=0
Enabled=1
Gpgkey=https://packages.gitlab.com/gpg.key

然后创建cache,再直接安装gitlab-ce

 
yum makecache  # 这一步会创建大量的数据

# 直接安装最新版
yum install -y gitlab-ce 

# 如果要安装指定的版本,在后面填上版本号即可
yum install -y  gitlab-ce-13.6.1

# 如果安装时出现gpgkey验证错误,只需在安装时明确指明不进行gpgkey验证
yum install gitlab-ce -y --nogpgcheck

2.3 gitlab的配置

配置文件位置  /etc/gitlab/gitlab.rb

 
[root@centos7 test]# vim /etc/gitlab/gitlab.rb

[root@centos7 test]# grep "^[a-Z]" /etc/gitlab/gitlab.rb

external_url 'http://42.192.51.99:9091' # 这里一定要加上http://

 nginx['listen_port'] = 9091 # 配置邮件服务

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "82955503@qq.com"
gitlab_rails['smtp_password'] = "frumknxschkbcacd"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_pool'] = false

 gitlab_rails['gitlab_email_from'] = '82955503@qq.com'

 user['git_user_email'] =        "82955503@qq.com"

修改好配置文件后,要使用 gitlab-ctl reconfigure 命令重载一下配置文件,否则不生效。

 
gitlab-ctl reconfigure # 重载配置文件

报错:

execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8] (postgresql::enable line 49) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.
STDERR: initdb: error: invalid locale settings; check LANG and LC_* environment variables
---- End output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
Ran /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 returned 1
这是由于系统编码问题造成的,解决方法如下:
export LC_ALL=en_US.UTF-8 
export LANG=en_US.UTF-8 
export LANGUAGE=en_US.UTF-8
$ source ~/.bashrc

然后

gitlab-ctl reconfigure # 重载配置文件
gitlab-ctl start

端口是通了,但打开http://42.192.51.99:9091,报502错误

原因是8080端口被java占用,需要/etc/gitlab/gitlab.rb加上

  puma['port'] = 8101

然后

gitlab-ctl reconfigure # 重载配置文件
gitlab-ctl restart

 初始root密码在:/etc/gitlab/initial_root_password

标签:opt,gitlab,smtp,rails,yum,ce,安装
来源: https://www.cnblogs.com/zjhgx/p/15731486.html