#!/bin/bash
apt-get install -y curl openssh-server ca-certificates postfix
curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
#从清华大学下载,这样要比官网的快很多
echo ‘deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial main’ >/etc/apt/sources.list.d/gitlab-ce.list’
apt-get update
apt-get install -y gitlab-ce
gitlab-ctl reconfigure
gitlab-ctl status
#下面开始汉化
wget https://gitlab.com/xhang/gitlab/-/archive/v11.10.0-zh/gitlab-v11.10.0-zh.tar
tar -xvf gitlab-v11.10.0-zh.tar
cp -R /opt/gitlab/embedded/service/gitlab-rails /opt/gitlab/embedded/service/gitlab-rails.back
cp -rf gitlab-v11.10.0-zh/* /opt/gitlab/embedded/service/gitlab-rails/
#cp -rf后会报两个错误,这个没有关系不影响
gitlab-ctl reconfigure
gitlab-ctl restart
#如果看到 502 , Dont worry, 重启需要时间,等一分钟后再来看看
特别说明,上面的在18.04就不好用了,清华大学的那个源会报错
The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 14219A96E15E78F4
Reading package lists… Done
W: GPG error: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 14219A96E15E78F4
E: The repository ‘https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial InRelease’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
这个时候需要看下面这个
在Ubuntu18.04安装gitlab国内镜像加速
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
vim /etc/apt/sources.list.d/gitlab_gitlab-ce.list
#deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu bionic main
#deb-src https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu bionic main
apt-get update
apt-get install -y gitlab-ce
gitlab-ctl reconfigure
gitlab-ctl restart
如果gitlab执行有问题,可以使用命令 gitlab-ctl tail 来查看
修改gitlab端口
先关闭gitlab服务:gitlab-ctl stop
修改/etc/gitlab/gitlab.rb
vim /etc/gitlab/gitlab.rb
#unicorn[‘port’] = 8080 修改 8070 默认是注释的去掉前面的#
unicorn[‘port’] = 8070
#nginx[‘listen_port’] = nil 修改 8090 默认是注释的去掉前面的#
nginx[‘listen_port’] = 8090
邮箱配置
gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.163.com”
gitlab_rails[‘smtp_port’] = 465
gitlab_rails[‘smtp_user_name’] = "xxxx@163.com"
gitlab_rails[‘smtp_password’] = “xxxx”
gitlab_rails[‘smtp_domain’] = “163.com”
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_tls’] = true
gitlab_rails[‘gitlab_email_from’] = ‘xxxx@163.com’
邮箱修改配置后:需要修改,不然发送设置密码的邮件url不带端口
vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
命令行发邮件:
gitlab-rails console
Notify.test_email(‘xxx@163com’, ‘Message Subject’, ‘Message Body’).deliver_now
不知道为什么给qq邮箱发送失败
重新配置gitlab
gitlab-ctl reconfigure
重新启动gitlab
gitlab-ctl restart
最后也只是部分汉化了
部分命令
查看版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
以上文章仅作为笔记备份,部分内容转自:https://segmentfault.com/a/1190000015635824
https://blog.csdn.net/weixin_42190794/article/details/86714038