我有一个带有directadmin的VPS和很少的其他网站,我想安装gitlab而不会破坏其他网站。目前尝试但它将出现在所有域名上。似乎external_url
完全被忽略了。
答案 0 :(得分:1)
我花了一天时间弄清楚如何做到这一点,我将与其他人分享,希望它有所帮助!
如果你是像我这样的初学者,你应该知道这两件事:
1-所有配置均在/etc/gitlab/gitlab.rb
2-每次更改gitlab.rb时都必须运行gitlab-ctl reconfigure
和gitlab-ctl restart
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"
<强> OPTIONAL 强> 设置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中创建子域后,转到管理级别&gt;自定义HTTPD配置单击您的域并将以下文本粘贴到空白文本区域:(请注意,您应该将gitlab.your-domain.tld更改为您在gitlab.rb中为external_url设置的内容:
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设置,而不会破坏服务器上的其他站点。希望它有所帮助!
答案 1 :(得分:0)
使用Pezhvak的答案时,有可能所有CSS en 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]