2014-09-11 62 views
14

我已经安装了GitLab 7.2.1,其中Debian 7的.deb软件包来自GitLab.org,在我有root权限的虚拟服务器上。 在此虚拟服务器上,我已经安装了Apache版本2.2.22,我不想将Ngnix用于GitLab。GitLab 7.2.1与Apache服务器而不是Nginx

现在我不知道GitLab的公共文件夹在哪里,或者我必须做什么或者我必须注意什么。

所以我的问题是:我如何配置我的虚拟主机为Apache或我还必须做什么,我可以使用像我的apache web服务器上的“gitlab.example.com”的子域?

回答

17

考虑到两点:

  1. 独角兽是在8080上监听(你可以用sudo netstat -pant | grep unicorn检查)
  2. 你的文档根目录为/opt/gitlab/embedded/service/gitlab-rails/public

您可以创建一个新的虚拟主机在Apache中的gitlab具有以下配置:

<VirtualHost *:80> 
    ServerName gitlab.example.com 
    ServerSignature Off 

    ProxyPreserveHost On 

    <Location /> 
    Order deny,allow 
    Allow from all 

    ProxyPassReverse http://127.0.0.1:8080 
    ProxyPassReverse http://gitlab.example.com/ 
    </Location> 

    RewriteEngine on 
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
    RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA] 

    # needed for downloading attachments 
    DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public 

</VirtualHost> 
+2

您可能还需要sudo a2enmod proxy_http – xtian 2015-04-08 15:42:14

+4

如果您收到权限错误,如“您无权访问此服务器上的/assets/logo-white-0b53cd4ea06811d79b3acd486384e047.png”。那么你需要“需要全部授予” xtian 2015-04-08 15:46:40

+2

我的独角兽进程名是config.ru,所以我subjet使用netstat -pant | grep 8080 – themadmax 2015-08-12 14:40:16

9

我跟着这篇文章http://eserdeniz.fr/articles/view/4/installer-gitlab-sous-debian-7-avec-nginx-et-mysql它工作,但我需要Apache而不是Nginx。

在使用gitlab-ce 7.9.0.rc3配置apache2有很多麻烦之后,我查看了关于ProxyPass和ProxyPassReverse指令的apache文档。

我解决我的问题,这个虚拟主机:

<VirtualHost *:80> 
      ServerName gitlab.me 

      # those options below are recommanded by apache, dealing with the simple Proxy we need for gitlab 
      ProxyRequests Off 
      ProxyPreserveHost On 
      AllowEncodedSlashes NoDecode 

      # here we don't want to proxify the requests for the existing assets in gitlab's public directory 
      ProxyPassMatch ^(/[^/]+\.(html|png|ico|css|txt))$ ! 
      ProxyPass /assets ! 

      # here we "redirect" the requests for http://gitlab.me/ to http://127.0.0.1:8080/ 
      ProxyPass/http://127.0.0.1:8080/ 

      # here we "rewrite" the redirections form unicorn for http://127.0.0.1:8080/ into http://gitlab.me/ 
      ProxyPassReverse/http://127.0.0.1:8080/ 

      # And of course the DocumentRoot to handle the assets requests 
      DocumentRoot /home/git/gitlab/public/ 

      # In the last versions of apache, there is a deny,allow default order so we put those two sections to prevent 'client denied by server configuration' 403 error 

      <Directory /home/git/gitlab/public/> 
        # apache 2.2 
        Order allow,deny 
        Allow from all 

        # apache 2.4 
        Require all granted 
      </Directory> 

      <Location /> 
        # apache 2.2 
        Order allow,deny 
        Allow from all 

        # apache 2.4 
        Require all granted 
      </Location> 
    </VirtualHost> 

现在,它的速度极快!

希望这会有所帮助!

2

如果你有HTTP访问的git看问题,这样的配置:

# cat /etc/gitlab/gitlab.rb | grep -v '^$\|^\s*\#' 
external_url 'http://gitlab.example.fr' 
web_server['external_users'] = ['www-data'] 
nginx['enable'] = false 
ci_nginx['enable'] = false 
gitlab_git_http_server['listen_network'] = "tcp" 
gitlab_git_http_server['listen_addr'] = "localhost:8282" 

和Apache2的配置:

# cat /etc/apache2/sites-enabled/gitlab 
<VirtualHost *:80> 
     ServerName gitlab.example.fr 
     ProxyRequests Off 
     ServerSignature Off 
     ProxyPreserveHost On 
     AllowEncodedSlashes NoDecode 
     ProxyPassMatch ^(/[^/]+\.(html|png|ico|css|txt))$ ! 
     ProxyPass /assets ! 
     ProxyPass/http://127.0.0.1:8080/ 
     ProxyPassReverse/http://127.0.0.1:8080/ 
     RewriteEngine on 
     RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
     RewriteRule /[-\/\w\.]+\.git\/ http://127.0.0.1:8282%{REQUEST_URI} [P,QSA,L] 
     DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public 
      <Directory /opt/gitlab/embedded/service/gitlab-rails/public/> 
        Order allow,deny 
        Allow from all 
      </Directory> 
      <Location /> 
        Order allow,deny 
        Allow from all 
      </Location> 
</VirtualHost> 

应用更改:

# gitlab-ctl reconfigure 
# service apache2 reload 

https://gitlab.com/gitlab-org/gitlab-ce/issues/2669#note_2176671

0

从源头安装。 gitlab 7.4.5

独角兽正在监听9095.Apache是​​2.2.9,我没有使用https。

System information 
System:   CentOS 6.7 
Current User: git 
Using RVM:  no 
Ruby Version: 2.1.2p95 
Gem Version: 2.2.2 
Bundler Version:1.11.2 
Rake Version: 10.3.2 
Sidekiq Version:2.17.0 

GitLab information 
Version:  7.4.5 
Revision:  19d572e 
Directory:  /home/git/gitlab 
DB Adapter:  mysql2 
URL:   http://gitlab.example.com 
HTTP Clone URL: http://gitlab.example.com/some-project.git 
SSH Clone URL: [email protected]:some-project.git 
Using LDAP:  no 
Using Omniauth: no 

GitLab Shell 
Version:  2.0.1 
Repositories: /home/git/repositories/ 
Hooks:   /home/git/gitlab-shell/hooks/ 
Git:   /usr/bin/git 

修改configuration file apache 2.2适合我。

gitlab 6.0的另一个旧配置文件是here,它也适用于我。

#This configuration has been tested on GitLab 8.0.0 
#Note this config assumes unicorn is listening on default port 8080 and gitlab-git-http-server is listening on port 8181. 
#To allow gitlab-git-http-server to listen on port 8181, edit or create /etc/default/gitlab and change or add the following: 
#gitlab_git_http_server_options="-listenUmask 0 -listenNetwork tcp -listenAddr localhost:8181 -authBackend http://127.0.0.1:8080" 

#Module dependencies 
# mod_rewrite 
# mod_proxy 
# mod_proxy_http 
# HTTP Configuration 
<VirtualHost *:80> 
    ServerName gitlab.example.com 
    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 

    # 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 /> 
     #Require all granted 
     Order deny,allow 
     Allow from all 

     #Allow forwarding to gitlab-git-http-server 
     #ProxyPassReverse http://127.0.0.1:8181 
     #Allow forwarding to GitLab Rails app (Unicorn) 
     ProxyPassReverse http://127.0.0.1:9095 
     ProxyPassReverse http://gitlab.example.com/ 
    </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 these requests to gitlab-git-http-server 
    #Forward these requests to gitlab-git-http-server 
    #RewriteCond %{REQUEST_URI} ^/[\w\.-]+/[\w\.-]+/repository/archive.* [OR] 
    #RewriteCond %{REQUEST_URI} ^/api/v3/projects/.*/repository/archive.* [OR] 
    #RewriteCond %{REQUEST_URI} ^/[\w\.-]+/[\w\.-]+/(info/refs|git-upload-pack|git-receive-pack)$ 
    #RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA] 

    #Forward any other requests to GitLab Rails app (Unicorn) 
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR] 
    RewriteCond %{REQUEST_URI} ^/uploads 
    RewriteRule .* http://127.0.0.1:9095%{REQUEST_URI} [P,QSA,NE] 

    # needed for downloading attachments 
    DocumentRoot /home/git/gitlab/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 503 /deploy.html 

    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded 
    ErrorLog logs/gitlab.example.com_error.log 
    CustomLog logs/gitlab.example.com_forwarded.log common_forwarded 
    CustomLog logs/gitlab.example.com_access.log combined env=!dontlog 
    CustomLog logs/gitlab.example.com.log combined 

</VirtualHost> 

希望对从源代码安装gitlab旧版本的人有用。

3

的Debian GNU/Linux的8.4(杰西)用总括8.5.0(apt-get的)版本:

GitLab配置

# cat /etc/gitlab/gitlab.rb | grep -v '^$\|^\s*\#' 
external_url 'http://gitlab.example.fr' 
gitlab_workhorse['enable'] = true 
gitlab_workhorse['listen_network'] = "tcp" 
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181" 
web_server['external_users'] = ['www-data'] 
nginx['enable'] = false 

的Apache2配置

# cat /etc/apache2/sites-enabled/gitlab.conf | grep -v '^$\|^\s*\#' 
<VirtualHost *:80> 
    ServerName gitlab.example.fr 
    ServerSignature Off 
    ProxyPreserveHost On 
    AllowEncodedSlashes NoDecode 
    <Location /> 
    Require all granted 
    ProxyPassReverse http://127.0.0.1:8181 
    ProxyPassReverse http://gitlab.example.fr/ 
    </Location> 
    RewriteEngine on 
    RewriteCond %{REQUEST_URI} ^/api/v3/.* 
    RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE] 
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR] 
    RewriteCond %{REQUEST_URI} ^/uploads/.* 
    RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA] 
    DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public 
    ErrorDocument 404 /404.html 
    ErrorDocument 422 /422.html 
    ErrorDocument 500 /500.html 
    ErrorDocument 503 /deploy.html 
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded 
    ErrorLog /var/log/apache2/gitlab_error.log 
    CustomLog /var/log/apache2/gitlab_forwarded.log common_forwarded 
    CustomLog /var/log/apache2/gitlab_access.log combined env=!dontlog 
    CustomLog /var/log/apache2/gitlab.log combined 
</VirtualHost> 

的Netstat输出

# netstat -pant 
Active Internet connections (servers and established) 
Proto Recv-Q Send-Q Local Address   Foreign Address   State  PID/Program name 
tcp  0  0 127.0.0.1:5432   0.0.0.0:*    LISTEN  11849/postgres 
tcp  0  0 127.0.0.1:8080   0.0.0.0:*    LISTEN  23736/config.ru 
tcp  0  0 127.0.0.1:8181   0.0.0.0:*    LISTEN  26061/gitlab-workho 

来源

https://gitlab.com/gitlab-org/gitlab-recipes/blob/master/web-server/apache/gitlab-omnibus-apache24.conf

http://doc.gitlab.com/omnibus/settings/nginx.html#using-a-non-bundled-web-server

0

使用@ pincoded的回答,我是能够得到GitLab启动和运行,但推动改变的时候,我总是收到一个500错误。

然后我在@themadmax的答案中使用了由GitLab提供的apache的官方配置。这里的问题是服务器永远不可达,并在一段时间后产生了502错误。

我的解决办法:使用 通过the official solution GitLab(小心,记得要选择在这个环节上的SSL配置,如果你只运行GitLab SSL)但以下this forum entry我不得不再次打开nginx的ON。

所以最后我的配置是这样的:

虚拟主机:

<VirtualHost *:80> 
    ServerName YOUR_SERVER_FQDN 
    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 /> 
    # New authorization commands for apache 2.4 and up 
    # http://httpd.apache.org/docs/2.4/upgrading.html#access 
    Require all granted 

    #Allow forwarding to gitlab-workhorse 
    ProxyPassReverse http://127.0.0.1:8181 
    ProxyPassReverse http://YOUR_SERVER_FQDN/ 
    </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 

</VirtualHost> 

gitlab.ru:

# nginx['enable'] = false # this defaults to true 
gitlab_workhorse['enable'] = true 
gitlab_workhorse['listen_network'] = "tcp" 
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181" 
1

对于最近旅行者GitLab 10.XX有看看this repo。您可以找到Apache2配置文件以及那里的说明,让GitLab仅在禁用Apache2和NGINX的情况下运行。

相关问题