【发布时间】:2018-08-17 17:30:23
【问题描述】:
我有一个带有 directadmin 和几个其他网站的 VPS,我想在不损坏其他网站的情况下安装 gitlab。目前已尝试,但它会显示在所有域上。似乎 external_url 被完全忽略了。
【问题讨论】:
标签: gitlab centos7 directadmin
我有一个带有 directadmin 和几个其他网站的 VPS,我想在不损坏其他网站的情况下安装 gitlab。目前已尝试,但它会显示在所有域上。似乎 external_url 被完全忽略了。
【问题讨论】:
标签: gitlab centos7 directadmin
我花了一天的时间才弄清楚如何做,我将与他人分享,希望对您有所帮助!
如果你像我一样是初学者,你应该知道这两件事:
1-所有配置都在/etc/gitlab/gitlab.rb
2- 每次更改 gitlab.rb 时都必须运行 gitlab-ctl reconfigure 和 gitlab-ctl restart
好的..问题是gitlab默认与nginx捆绑在一起,它会破坏你的apache设置。为了解决这个问题。
1- 打开你的 gitlab.rb 配置文件:nano /etc/gitlab/gitlab.rb
2- 确保您的 external_url 设置正确,例如:gitlab.your-domain.tld
3-查找并设置nginx['enable'] = false,默认为注释,去掉行首的#即可取消注释。
4- 查找并设置web_server['external_users'] = ['admin'] 这非常重要,因为directadmin 没有使用默认的apache 用户'www-data'
5- 查找并设置gitlab_workhorse['listen_network'] = "tcp"
6- 最后设置gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
可选 要设置 smtp 服务器,请在您的 directadmin 中创建一个电子邮件帐户,然后通过更新以下配置进行设置:
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "mail.domain.tld"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "gitlab@domain.tld"
gitlab_rails['smtp_password'] = "email_password_here"
gitlab_rails['smtp_domain'] = "domain.tld"
gitlab_rails['smtp_authentication'] = "plain"
gitlab_rails['smtp_enable_starttls_auto'] = false
现在保存文件并运行gitlab-ctl reconfigure 然后gitlab-ctl restart 以使更改生效。
现在你的 gitlab 已经准备好了,你现在要做的就是创建你使用的子域 ex: gitlab 为你的域。在您的 directadmin 中创建子域后,转到 Admin Level > Custom HTTPD Configurations 单击您的域并将以下文本粘贴到空白文本区域:(请注意,您应该将 gitlab.your-domain.tld 更改为您为 external_url 设置的任何内容在 gitlab.rb 中:
ServerName gitlab.your-domain.tld
ServerSignature Off
ProxyPreserveHost On
# Ensure that encoded slashes are not decoded but left in their encoded state.
# http://doc.gitlab.com/ce/api/projects.html#get-single-project
AllowEncodedSlashes NoDecode
<Location />
Order deny,allow
Allow from all
#Allow forwarding to gitlab-workhorse
ProxyPassReverse http://127.0.0.1:8181
ProxyPassReverse http://gitlab.your-domain.tld/
</Location>
# Apache equivalent of nginx try files
# http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
# http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
RewriteEngine on
#Forward all requests to gitlab-workhorse except existing files like error documents
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads/.*
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
# needed for downloading attachments
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
#Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
ErrorDocument 404 /404.html
ErrorDocument 422 /422.html
ErrorDocument 500 /500.html
ErrorDocument 502 /502.html
ErrorDocument 503 /503.html
就是这样!您现在应该可以使用您的 gitlab 设置,而不会破坏您服务器上的其他站点。希望有帮助!
【讨论】:
使用 Pezhvak 的答案时,可能所有 CSS 和 JS 文件都没有加载。我通过更改 HTTPD conf 部分解决了这个问题:
#Forward all requests to gitlab-workhorse except existing files like error documents
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads/.* [OR]
RewriteCond %{REQUEST_URI} ^/assets/.*
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
【讨论】: