在Debian系统上配置GitLab时,选择合适的数据库至关重要。以下是推荐的数据库及其配置步骤:
PostgreSQL数据库
MySQL/MariaDB数据库
准备工作
sudo apt update
sudo apt upgrade
sudo apt install curl openssh-server ca-certificates postfix
添加GitLab官方仓库
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt install gitlab-ce
配置GitLab
/etc/gitlab/gitlab.rb
文件,找到并修改以下参数:
external_url
: 设置为你的服务器地址,例如 http://your_server_ip
。gitlab_rails['gitlab_email_enabled']
: 设置为 true
以启用邮件功能。gitlab_rails['gitlab_email_from']
: 设置为你选择的邮件地址。gitlab_rails['smtp_enable']
: 设置为 true
以启用SMTP邮件发送功能。gitlab_rails['smtp_address']
, gitlab_rails['smtp_port']
, gitlab_rails['smtp_user_name']
, gitlab_rails['smtp_password']
, gitlab_rails['smtp_domain']
: 设置为你选择的SMTP邮件服务器信息。sudo gitlab-ctl reconfigure
优化GitLab性能
配置HTTPS
/etc/gitlab/gitlab.rb
文件,添加或修改以下配置:letsencrypt['enable'] = true
letsencrypt['auto_renew'] = true
letsencrypt['contact_emails'] = ['your-email@example.com']
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
完成以上步骤后,您可以通过浏览器访问GitLab的Web界面,并根据提示设置管理员账户的密码。