如何使用Apache和Passenger在子域根目录上部署Rails应用程序

时间:2013-07-19 19:02:41

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

我在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>

我尝试了很多组合和谷歌搜索时间,但没有任何作用。

如何更改此配置以在子域root上部署redmine?

提前致谢。

3 个答案:

答案 0 :(得分:5)

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

当我一次又一次地阅读本手册时,我找到了解决方案: 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>

答案 1 :(得分:0)

部署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>

答案 2 :(得分:0)

我在Debian 9.0 Stretch服务器上使用分发版本提供的软件包(Apache + Redmine + Ruby + Rails + Passenger + MariaDB)或多或少地按照这些指南安装了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 restart apache2

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

相关问题