我已经使用nginx和Phusion Passenger配置了一个Rails应用程序。当我在http://hostname/vns/
访问该网站时,所有内容都正确加载但我看到所请求的字体文件有404个错误:
open() "/sites/apps/assets/fontawesome-webfont-f1c2889911d212e1403b68eabc1a3a5
6.svg" failed (2: No such file or directory)
该应用程序位于/ sites / ruby-apps / application /和/ sites / apps / vns是/ sites / ruby-apps / application / public /
的符号链接当我查看rake assets:precompile
生成的CSS时,我发现公共/资产中有两个application.css文件。
application.css在src中列出了正确的路径:url(“/ vns/assets/fontawesome-webfont.eot”) application-md5fingerprint.css没有正确的路径(“/assets/fontawesome-webfont-009f6d1f667cc42c25e712ab3429cbc7.eot”)
根据我到目前为止试图弄清楚我应该使用RAILS_RELATIVE_URL_ROOT,但到目前为止,当我将它包含在我的production.rb文件中时似乎没有任何影响:
ENV['RAILS_RELATIVE_URL_ROOT'] = "/vns"
我配置的相关部分:
http {
...
passenger_root /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10;
passenger_ruby /usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby;
passenger_max_pool_size 10;
passenger_pool_idle_time 0;
passenger_log_level 0;
passenger_debug_log_file /var/log/nginx/passenger.log;
...
}
server {
...
passenger_base_uri /vns;
location /vns {
passenger_enabled on;
}
...
}
如果有人能帮助我指出解决问题的正确方向,我将非常感激。
答案 0 :(得分:1)
我经过几个小时的试图解决它并在五分钟后解决了我自己的问题后发布了这个。包括其他可能会发现这个问题的答案:
看起来我正在使用ENV ['RAILS_RELATIVE_URL_ROOT']不正确。
当我将它移动到我的资产预编译行时,如下所示:
RAILS_RELATIVE_URL_ROOT='/vns' rake assets:precompile
一切都按预期发布了。我对Rails不太熟悉,不知道我做错了什么,或者是否有更好的方法可以解决这个问题,但这对我来说已经解决了。