更新时间:2023-02-23 17:20:44
我花了一天的时间弄清楚该怎么做,我将与他人分享,希望对您有所帮助!
it took me a day to figure out how to do it and i'm gonna share it with others, hope it helps!
如果您是像我这样的初学者,则应该了解以下两点:
if you're a beginner like me you should know these two things:
1-所有配置都在/etc/gitlab/gitlab.rb
2-每次更改gitlab.rb时,都必须运行gitlab-ctl reconfigure
和gitlab-ctl restart
2- every time you change gitlab.rb you have to run gitlab-ctl reconfigure
and gitlab-ctl restart
好的..问题是gitlab默认情况下与nginx捆绑在一起,它将破坏您的apache设置.为了解决这个问题.
ok.. the problem is that gitlab is bundled with nginx by default and it will break your apache setup. in order to fix that.
1-打开您的gitlab.rb配置文件:nano /etc/gitlab/gitlab.rb
1- open your gitlab.rb configuration file: nano /etc/gitlab/gitlab.rb
2-确保您的external_url设置正确,如:gitlab.your-domain.tld
2- make sure your external_url is set correctly like: gitlab.your-domain.tld
3-查找并设置nginx['enable'] = false
,默认情况下已注释,将行开头的#删除以取消注释.
3- find and set nginx['enable'] = false
, it's commented by default, remove # from the beginning of the line to uncomment.
4-查找并设置web_server['external_users'] = ['admin']
这非常重要,因为directadmin没有使用默认的apache用户'www-data'
4- find and set web_server['external_users'] = ['admin']
it's very important since directadmin is not using default apache user 'www-data'
5-查找并设置gitlab_workhorse['listen_network'] = "tcp"
6-并最终设置gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
可选 要设置smtp服务器,请在您的directadmin中创建一个电子邮件帐户,然后通过更新以下配置进行设置:
OPTIONAL to set smtp server create an email account in your directadmin and then set it by updating following configurations:
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
,以使更改生效.
now save the file and run gitlab-ctl reconfigure
then gitlab-ctl restart
in order changes take effect.
现在您已经准备好gitlab,现在要做的就是创建您以前使用的子域:gitlab作为您的域.在directadmin中创建子域后,请转到管理员级别">自定义HTTPD配置",然后单击您的域并将以下文本粘贴到空白文本区域:(请注意,您应将gitlab.your-domain.tld更改为为external_url设置的任何值在gitlab.rb中:
now you're gitlab is ready, all you have to do now is to create subdomain that you used ex: gitlab for your domain. after you created the subdomain in your directadmin go to Admin Level > Custom HTTPD Configurations click on your domain and paste the following text into the blank text area: (note that you should change gitlab.your-domain.tld to whatever you set for external_url in 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://***.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设置,而不必破坏服务器上的其他站点.希望对您有帮助!
that's it! you should be able to use your gitlab setup now without breaking other sites on your server. hope it helps!