【问题标题】:How to deploy Rails app on subdomain root with Apache and Passenger如何使用 Apache 和 Passenger 在子域根目录上部署 Rails 应用程序
【发布时间】:2013-07-19 19:02:41
【问题描述】:

我在 sub-uri redmine.example.org/redmine 上有工作的 Rails 应用程序,我希望它在 redmine.example.org

/var/www/work/redmine.src is approot
/var/www/work/redmine is symlink to /var/www/work/redmine.src/public

<VirtualHost *:80>
    DocumentRoot /var/www/work
    ServerName redmine.example.org

    ErrorLog /var/log/apache2/redmine-error_log
    CustomLog /var/log/apache2/redmine-access_log combined

    <Directory /var/www/work/redmine>
            AllowOverride all
            Options -MultiViews
            Order allow,deny
            allow from all
    </Directory>

    RackBaseURI /redmine
    <Directory /var/www/work/redmine.src>
            Options -MultiViews
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

我尝试了许多组合并在谷歌上搜索了几个小时,但没有任何效果。

我应该如何更改此配置以在子域根目录上部署 redmine?

提前致谢。

【问题讨论】:

    标签: ruby-on-rails ruby apache deployment passenger


    【解决方案1】:

    嗯,这比我想象的要容易。

    当我一遍又一遍地阅读手册时,我找到了解决方案: link to manual

    现在我的配置文件如下所示:

    <VirtualHost *:80>
        DocumentRoot /var/www/work/redmine.src/public
        ServerName redmine.example.org
    
        <Directory /var/www/work/redmine.src/public>
            AllowOverride all
            Options -MultiViews
            Order allow,deny
            allow from all
        </Directory>
    </VirtualHost>
    

    【讨论】:

      【解决方案2】:

      另一种部署 sub-uri 应用程序的方法,也可能对您有用:

      <VirtualHost *:80>
          ProxyPass /sub_uri/ http://localhost:8000/sub_uri/
      
          DocumentRoot /main_app/public
          <Directory /main_app/public>
             ...
          </Directory>
      </VirtualHost>
      
      <VirtualHost *:8000>
        DocumentRoot /sub_uri/public
        <Directory /sub_uri/public>
          ...
          SetEnv RAILS_RELATIVE_URL_ROOT /sub_uri
        </Directory>
      </VirtualHost>
      

      【讨论】:

      • 我没有启用 mod_proxy,我希望有更好的解决方案。但我会尝试...
      【解决方案3】:

      我使用发行版本身提供的软件包(Apache + Redmine + Ruby + Rails + Passenger + MariaDB)在 Debian 9.0 Stretch 服务器上安装了 Redmine 3.3.1,或多或少遵循了这些指南:

      http://www.redmine.org/projects/redmine/wiki/RedmineInstall http://www.redmine.org/projects/redmine/wiki/InstallRedmineOnDebianStableApacheMysqlPassenger

      我想留下www.example.org“for Apache”和redmine.example.org“for Redmine”,所以我完成了以下设置。

      我保持 /etc/apache2/sites-available/000-default.conf 不变,并在同一个文件夹中创建了一个名为 redmine.conf 的文件:

      <VirtualHost *:80>
          ServerName redmine.example.org
          DocumentRoot /usr/share/redmine/public
          PassengerRuby /usr/bin/ruby
          <Directory /usr/share/redmine/public>
              Allow from all
              Options -MultiViews
              Require all granted
          </Directory>
      </VirtualHost>
      

      然后,我已将其链接到 sites-enabled 文件夹并重新启动 Apache:

      # ln -s /etc/apache2/sites-available/redmine.conf /etc/apache2/sites-enabled/redmine.conf # systemctl 重启 apache2

      要设置该虚拟主机,我按照此处的说明进行操作:

      【讨论】:

        猜你喜欢
        • 2018-01-13
        • 1970-01-01
        • 2023-03-29
        • 2017-08-04
        • 2011-04-24
        • 1970-01-01
        • 2013-06-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多