一、配置外部SMTP邮箱服务器

1. 配置163邮箱服务器

# vim /etc/gitlab/gitlab.rb                            
 
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25 
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "xxxx"  # 此密码非163邮箱密码,而是客户端授权码
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true

gitlab_rails['gitlab_email_from'] = "[email protected]"
user["git_user_email"] = "[email protected]"

2. 重新应用配置文件

# gitlab-ctl reconfigure


二、GitLab目录管理

Default location Permissions Ownership Purpose
/var/opt/gitlab/git-data 0700 git:root Holds repositories directory
/var/opt/gitlab/git-data/repositories 2770 git:git Holds git repositories
/var/opt/gitlab/gitlab-rails/shared 0751 git:gitlab-www Holds large object directories
/var/opt/gitlab/gitlab-rails/shared/artifacts 0700 git:root Holds CI artifacts
/var/opt/gitlab/gitlab-rails/shared/lfs-objects 0700 git:root Holds LFS objects
/var/opt/gitlab/gitlab-rails/uploads 0700 git:root Holds user attachments
/var/opt/gitlab/gitlab-rails/shared/pages 0750 git:gitlab-www Holds user pages
/var/opt/gitlab/gitlab-ci/builds 0700 git:root Holds CI build logs
/var/opt/gitlab/.ssh 0700 git:git Holds authorized keys

1. 修改GitLab仓库目录

默认情况下GitLab将仓库数据存储在 /var/opt/gitlab/git-data目录下,仓库存放在子目录 repositories里面。 以可以通过修改/etc/gitlab/gitlab.rb 的这一行来自定义 git-data 的父目录。

git_data_dirs({ "default" => { "path" => "/mnt/nas/git-data" } })

从GitLab 8.10开始,可以通过在/etc/gitlab/gitlab.rb文件中添加下面的几行配置, 来增加多个 git 数据存储目录。

git_data_dirs({
  "default" => { "path" => "/var/opt/gitlab/git-data" },
  "alternative" => { "path" => "/mnt/nas/git-data" }})

2. 设置仅在指定文件系统挂载后启动服务

如果要在挂载给定文件系统之前阻止gitlab服务(NGINX,Redis,Unicorn等)启动,请将以下内容添加到/etc/gitlab/gitlab.rb:

# wait for /var/opt/gitlab to be mounted
high_availability['mountpoint'] = '/var/opt/gitlab'