如何设置 Apache conf 以及可能的 Passenger 以允许更多虚拟主机在一个代码库上运行
我的代码库根据标识符 (OXID) 对用户进行分段,但我希望分段的用户有单独的 public 文件夹,并且我可以在不骚扰其他网站的情况下关闭某个网站 - 这这就是为什么我希望我的 httpd.conf 包含看起来像这样:
<VirtualHost *:80>
ServerName ny1.alco.dk
DocumentRoot /var/www/html/alco/current/sites/user_A/public
PassengerAppRoot /var/www/html/alco/current
SetEnv OXID 23
</VirtualHost>
<VirtualHost *:80>
ServerName ny2.alco.dk
DocumentRoot /var/www/html/alco/current/sites/user_B/public
PassengerAppRoot /var/www/html/alco/current
SetEnv OXID 25
</VirtualHost>
Apache 对此很酷 - 但 Passenger 咆哮着“没有这样的文件要加载 - 捆绑程序” - 很明显,这是不对的!
这是否可能(至少对于 Apache/2.2.14 (Unix)、Ruby 1.8.7 p330、Rails 3.0.3 和 Passenger 3.0.2)
更新!
事实证明,乘客“吠叫”在我身上:(
我已经启动并运行了 2 个站点 - 但两个站点都报告了第一个被访问主机的 ENV['OXID']!?即,如果我浏览 ny1.alco。 dk/something - 我得到“23”,这很好,但如果我随后浏览到 ny2.alco.dk,我也会得到“23”!?同样 - 如果我浏览到 ny2.alco.dk/something 作为之后的第一件事触摸 tmp/restart.txt,我得到“25”,这与随后浏览 ny1.alco.dk 时得到的值相同 - 嗯
My codebase segments users on an identifier (OXID) but I would like the segmented users have separate public folders, and for me to take a site down without harassing other sites - which is why I would like my httpd.conf inclusion to look like this:
<VirtualHost *:80>
ServerName ny1.alco.dk
DocumentRoot /var/www/html/alco/current/sites/user_A/public
PassengerAppRoot /var/www/html/alco/current
SetEnv OXID 23
</VirtualHost>
<VirtualHost *:80>
ServerName ny2.alco.dk
DocumentRoot /var/www/html/alco/current/sites/user_B/public
PassengerAppRoot /var/www/html/alco/current
SetEnv OXID 25
</VirtualHost>
Apache is cool with this - but Passenger barks with "no such file to load -- bundler" - so obviously, this is not right!
Is this at all possible (at least with Apache/2.2.14 (Unix), Ruby 1.8.7 p330, Rails 3.0.3, and Passenger 3.0.2)
Update!
Turns out that the Passenger 'bark' was on me :(
I have the 2 sites up and running - but both sites report the ENV['OXID'] of the first host being accessed!? Ie. if I browse ny1.alco.dk/something - I get '23' which is good, but I also get '23' if I then browse to ny2.alco.dk!? Likewise - if I browse to ny2.alco.dk/something as the first thing after touching tmp/restart.txt, I get '25' which will be the same value I get, when subsequently browsing to ny1.alco.dk - Hmmmm
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许这是一个黑客 - 我需要进一步调查,但是:
如果我这样做
,然后编辑我的 /data/apache/conf.d/alco.conf 来保持
我很好:)
我仍然想要第二意见这个——但现在;我很好:)
Perhaps it is a hack - I'll need to investigate further but:
If I do
and then edit my /data/apache/conf.d/alco.conf to hold
I'm good :)
I'd still like second opinions on this one - but for now; I'm good :)
Rails 3.2.0 包含一个
config.ru
,它似乎确实是罪魁祸首 - 完全删除它确实解决了我的多站点问题。所以,到目前为止,我们的教训是,如果您想在类似的站点之间共享代码,Rails 应用程序并不容易进行搜索!
Rails 3.2.0 includes a
config.ru
which really seems to be the culprit - removing it altogether did solve my multi-site problem.So, lesson - so far - is that Rails apps do not lend easy to raking if you like to share code between like sites!