繁体   English   中英

为什么Rails应用程序可以从端口而不是子域正常运行?

[英]Why does a Rails Application run properly from a port but not from a subdomain?

这是我的/ etc / apache2 / sites-available / default文件的内容

NameVirtualHost *:80

<VirtualHost *:80>
   ServerName domain.com
         # !!! Be sure to point DocumentRoot to ('public')!
   DocumentRoot /var/www
</VirtualHost>

<VirtualHost *:80>
   ServerName a.domain.com
             # !!! Be sure to point DocumentRoot to ('public')!
   DocumentRoot /home/user/A/public
   <Directory /home/user/A/public>
    AllowOverride all
    Options -MultiViews
   </Directory>
</VirtualHost>

<VirtualHost *:80>
   ServerName b.domain.com
             # !!! Be sure to point DocumentRoot to ('public')!
   DocumentRoot /home/user/B/public
   <Directory /home/user/B/public>
    AllowOverride all
    Options -MultiViews
   </Directory>
</VirtualHost>

<VirtualHost *:80>
   ServerName c.domain.com
             # !!! Be sure to point DocumentRoot to ('public')!
    DocumentRoot /home/user/C
    <Directory /home/user/C/public>
    AllowOverride all
    Options -MultiViews
   </Directory>
</VirtualHost>

目的是将子域名(例如a.domain.com)“链接”到在特定端口上运行的Rails应用程序(同一服务器上有多个低强度的Rails应用程序)。 上面显示的配置可重定向到适当的静态页面AND / OR rails应用程序,但其中一个存在问题:

通过以下方式访问时,有问题的Rails应用程序可以正常运行:domain.com:port(或domain.com:4444)

但是,当尝试通过以下方式访问同一Rails应用程序时:c.domain.com(链接到Rails应用程序所在目录的子域)会引发以下错误:

https://github.com/net-ssh/net-ssh (at master) is not yet checked out. Run `bundle install` first. (Bundler::GitError)

需要明确的是,当从domain.com:port访问该同一个Rails应用程序时,它可以正常工作,但是使用c.domain.com失败

由于集合中的一个Rails应用程序正常工作,而另一个失败了,我感到非常困惑。 到目前为止,我在搜索中找不到类似的内容。

问题和建议非常欢迎。

谢谢〜艾伦

新闻:我仍在阅读文档,试图了解为什么通过端口或子域(domainname.com:port .vs.sub.domainname.com)访问Rails应用程序的行为会有所不同。 但是,我确实确定让apache为目录结构的所有者有助于通过子域工作来访问。 (apache用户= www-data)

chown -R www-data:www-data /home/user/app

解决了其中一个Rails应用程序的问题。 公共目录中还有一个.htaccess文件,必须将其删除,并且需要使用此版本的bundle命令:

bundle install --path vendor/bundle

子域上运行的其他应用程序不需要这些。

看来我已经从技术上解决了这个难题,但是我仍然不明白为什么对于一个应用程序而不是另一个应用程序是必需的。

您的文档是否将所有符号链接都根到同一个RAILS_ROOT目录? 还是在每个文档根目录中都有该应用程序的副本?

暂无
暂无

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

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