使用Apache Server而不是Nginx的GitLab 7.2.1

Rin*_*nma 16 apache nginx gitlab

我已经7.2.1使用GitLab.org的.deb软件包在我拥有root访问权限的虚拟服务器上为Debian 7 安装了GitLab .在这个虚拟服务器上,我已经安装了Apache,版本2.2.22,我不想将Ngnix用于GitLab.

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

所以我的问题是:我如何配置我的vhost for apache或我还需要做什么,我可以在我的apache web服务器上使用像"gitlab.example.com"这样的子域?

Bog*_*n T 21

考虑到两件事:

  1. Unicorn正在收听8080(您可以查看sudo netstat -pant | grep unicorn)
  2. 你的文档根目录是 /opt/gitlab/embedded/service/gitlab-rails/public

您可以使用以下配置在apache中为gitlab创建新的vhost:

<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>
Run Code Online (Sandbox Code Playgroud)

  • 如果您收到权限错误,例如"您无权访问此服务器上的/assets/logo-white-0b53cd4ea06811d79b3acd486384e047.png".然后你需要<Location>中的"Require all granted" (5认同)
  • 您可能还需要sudo a2enmod proxy_http (2认同)
  • 我的独角兽进程名称是config.ru,所以我subjet使用netstat -pant | grep 8080 (2认同)
  • 你如何让 gitlab-ce 不启动 nginx?我升级了 gitlab,它用 nginx 劫持了端口 80,阻止了我现有的 Apache 实例启动。gitlab _really_ 不想与现有服务共享服务器。 (2认同)
  • @arclight我知道这是事实之后的方法,但是我一天都被困在同一件事上。您必须在gitlab设置中禁用它,gitlab.rb我花了我几次尝试,但是找到了'nginx ['enable']`行并将其设置为false并删除了前导的标签。 (2认同)

sha*_*aft 11

我按照这篇文章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文档.

我用这个vhost解决了我的问题:

    <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>
Run Code Online (Sandbox Code Playgroud)

现在它的速度非常快!

希望这会有所帮助!