gitlab 配置邮箱,配置域名 中上级篇

配置邮箱:

  • 修改配置文件
    vim /etc/gitlab/gitlab.rb
## 配置SMTP邮件配置
    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.163.com"
    gitlab_rails['smtp_port'] = 25 
    gitlab_rails['smtp_user_name'] = "发件箱@163.com"
    gitlab_rails['smtp_password'] = "发件箱账号"
    gitlab_rails['smtp_domain'] = "163.com"
    gitlab_rails['smtp_authentication'] =login
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['gitlab_email_from'] = "发件箱@163.com"
    user["git_user_email"] = "发件箱@163.com"
    sudo gitlab-ctl reconfigure
    sudo gitlab-ctl restart

配置域名:

  • 修改配置文件
    vim /etc/gitlab/gitlab.rb
## 写好域名
    external_url 'http://xxx.xxx.xxx.xxx'
## 停掉他自带的nginx
    nginx['enable'] = false

* 配置域名的配置文件:*

  • 以nginx为例
# gitlab socket 文件地址
upstream gitlab {
  # 7.x 版本在此位置
  # server unix:/var/opt/gitlab/gitlab-rails/tmp/sockets/gitlab.socket;
  # 8.0 位置
  server unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
}

server
    {
        listen 80;
        #listen [::]:80;
        server_name XXX.XXX.XXX ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /opt/gitlab/embedded/service/gitlab-rails/public;

        include rewrite/none.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

         location / {
                 # serve static files from defined root folder;.
                 # @gitlab is a named location for the upstream fallback, see below
                try_files $uri $uri/index.html $uri.html @gitlab;
         }

        location @gitlab {
                 # If you use https make sure you disable gzip compression 
                 # to be safe against BREACH attack

                 proxy_read_timeout 300; # Some requests take more than 30 seconds.
                 proxy_connect_timeout 300; # Some requests take more than 30 seconds.
                 proxy_redirect     off;

                 proxy_set_header   X-Forwarded-Proto $scheme;
                 proxy_set_header   Host              $http_host;
                 proxy_set_header   X-Real-IP         $remote_addr;
                 proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
                 proxy_set_header   X-Frame-Options   SAMEORIGIN;

                 proxy_pass http://gitlab;
         }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/XXX.XXX.XXX.log;
    }                                

执行:

    gitlab-ctl reconfigure

你可能感兴趣的:(php,linux)