繁体   English   中英

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

[英]How to deploy Rails app on subdomain root with Apache and 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>

我尝试了许多组合和谷歌搜索时间,但没有任何效果。

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

提前致谢。

好吧,这比我想象的要容易。

当我一次又一次地阅读手册时,我找到了解决方法: 链接到手册

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

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

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

我使用发行版本身提供的软件包(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用于Apache)和redmine.example.org用于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-enabledsites-enabled文件夹,然后重新启动Apache:

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

要设置该虚拟主机,我按照以下说明进行操作:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM