搭建Gitlab服务器

在debianx系统上,采用Omnibus安装。

1.安装软件包

sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
sudo EXTERNAL_URL=”https://gitlab.example.com” apt-get install gitlab-ee

2.配置外部的Nginx(可选)

编辑/etc/gitlab/gitlab.rb修改以下内容

nginx['enable'] = false
web_server['external_users'] = ['www-data']
gitlab_rails['trusted_proxies'] = [ '127.0.0.1' ]
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "localhost:8001"

新增nginx站点配置文件

server {
listen 80;
server_name gitlab.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443;
server_name gitlab.example.com ;
ssl on;
ssl_certificate gitlab.example.com.crt;
ssl_certificate_key gitlab.example.com.key;
index index.html;
location / {
proxy_pass http://localhost:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Ssl on;
}
}

3.采用外部的SMTP服务器发送邮件(可选)

编辑/etc/gitlab/gitlab.rb修改以下内容

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.server"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "smtp user"
gitlab_rails['smtp_password'] = "smtp password"
gitlab_rails['smtp_domain'] = "example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true

4.完成

执行gitlab-ctl reconfigure重新配置
此时网站已经可以正常访问,登录修改网站相关设置即可

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据