文档地址:https://packages.gitlab.com/gitlab/gitlab-ce
一、安装gitlab所需依赖(如果没有)
$ sudo yum install curl openssh-server openssh-clients postfix cronie
安装之前可以先检查一下系统是否已经安装了上面的工具,如果已安装过就不用再安装了。
二、安装gitlab
$ curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
$ dnf install -y gitlab-ce
三、配置ssl证书
$ mkdir -p /etc/gitlab/ssl
$ cd /etc/gitlab/ssl
$ openssl genrsa -out "/etc/gitlab/ssl/gitlab.example.com.key" 2048
$ openssl req -new -key "/etc/gitlab/ssl/gitlab.lwt.com.key" -out "/etc/gitlab/ssl/gitlab.lwt.com.csr"
$ openssl x509 -req -days 365 -in "/etc/gitlab/ssl/gitlab.lwt.com.csr" -signkey "/etc/gitlab/ssl/gitlab.lwt.com.key" -out "/etc/gitlab/ssl/gitlab.lwt.com.crt"
$ openssl dhparam -out /etc/gitlab/ssl/dhparams.pem 2048
# 修改权限
$ chmod 600 *
# 修改gitlab.rb中的下面三项配置为前面步骤所创建的文件
# nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt"
# nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.lwt.com.key"
# nginx['ssl_dhparam'] = "/etc/gitlab/ssl/dhparams.pem"
$ vim /etc/gitlab/gitlab.rb
四、 初始化gitlab相关配置
# 初始化gitlab相关配置
$ gitlab-ctl reconfigure
五、修改/var/opt/gitlab/nginx/conf/gitlab-http.conf
server_name gitlab.example.com;
rewrite ^(.*)$ https://$host$1 permangent
六、重启gitlab服务
$ sudo gitlab-ctl restart
七、将gitlab服务器ip地址和上面配置的域名(gitlab.example.com)的对于关系配置到客户端电脑上(可选,可以直接使用ip访问)
window:(C:\Windows\System32\drivers\etc\hosts)
gitlabip gitlab.example.com
linux:(vim /etc/hosts)
gitlabip gitlab.example.com
ps:在Centos8上安装新版本的gitlab好像需要内存在2G以上,内存不足2G时初始化配置时会报错:
* Errno::ENOMEM occurred in delayed notification: execute[reload all sysctl conf] (package::sysctl line 18) had an error: Errno::ENOMEM: Cannot allocate memory - fork(2)
* Errno::ENOMEM occurred in delayed notification: runit_service[gitlab-workhorse] (gitlab::gitlab-workhorse line 49) had an error: Errno::ENOMEM: Cannot allocate memory - fork(2)