Ruby on Rails的设置:无法访问日志文件 [英] Ruby on Rails Setup: Unable to access log file
问题描述
我on Rails的首次设立红宝石;我的服务器上,我创建并加载默认的Rails应用程序。我可以查看默认页面(欢迎乘坐!你是骑导轨),但是当我去点击链接查看应用程序环境,它生成一个500错误。
I'm setting up Ruby on Rails for the first time; on my server, I've created and loaded the default rails app. I can view the default page ("Welcome aboard! You are riding Rails"), but when I go to click on the link to "View Application Environment", it generates a 500 error.
(你可以查看这里 。)
(You can view it here.)
我想知道更多有关该错误,但是,日志文件(登录/ production.log)是空的。看着我的Apache日志我发现:
I'd like to know more about the error, but, the log file ("log/production.log") is empty. Looking at my Apache log I find:
Rails的错误:无法访问日志文件。请确保
/var/www/rails/myapp/log/production.log存在且CHMOD 0666的
日志级别已经提升到WARN和输出定向到STDERR
直到问题得到解决。
Rails Error: Unable to access log file. Please ensure that /var/www/rails/myapp/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
所以,其实我是想获得我的Ruby on Rails的错误日志记录工作。
So, I actually want to get my Ruby on Rails error logging working.
我知道这个问题之前已经发布过几次,但我什么都试过了我能找到,所以这里是我曾尝试:
I know this problem has been posted a few times before, but I tried everything I could find, so here's what I have tried:
- 创建了登录/ production.log文件中,将店主www数据,请将
搭配chmod 0666
。 - 将日志文件夹的所有者
www数据
,设置搭配chmod 0666
。 - 双击选中我的生产环境设置,使得
config.log_level =:信息
设置 -
经过Apache是否使用www数据的用户(等/ apache2的/ envvars中):
- Created the "log/production.log" file, set the owner to www-data, set
chmod 0666
. - Set the owner of the "log" folder to
www-data
, setchmod 0666
. - Double-checked my production environment settings such that
config.log_level = :info
is set. Checked that Apache is using the www-data user ("etc/apache2/envvars"):
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
等/ apache2的/ MODS的可用/ passenger.conf有乘客默认用户组:
"etc/apache2/mods-available/passenger.conf" has a default user set for Passenger:
<IfModule mod_passenger.c>
PassengerRoot /usr
PassengerRuby /usr/bin/ruby
PassengerDefaultUser www-data
</IfModule>
config.ru和CONFIGS / environment.rb文件的所有者是 www数据
我的虚拟主机已被设置为:
My virtual host has been set accordingly:
DocumentRoot /var/www/rails/myapp/public
RackBaseURI /
RackEnv production
PassengerMaxPoolSize 4
已经看过,并试图在这些地方提出的所有修复:
Already read and attempted all the fixes suggested in these places:
- Rails的:无法访问日志文件
- 无法访问生产日志文件
- http://railsforum.com/viewtopic.php?id=36168
- Why我在对Capistrano的生成的文件的Permission denied错误的部署?
- HTTP ://bradhe.word$p$pss.com/2011/06/26/a-sneaky-rails-3-bug-in-logging/
- Rails: Unable to access log file
- Can't access log files in production
- http://railsforum.com/viewtopic.php?id=36168
- Why am I getting Permission denied error in deployment on files generated by capistrano?
- http://bradhe.wordpress.com/2011/06/26/a-sneaky-rails-3-bug-in-logging/
(这是我所记得的努力现在...)
(That's all I can remember trying right now...)
我的一些环境设置:
- 的Ubuntu 11.10在Amazon EC2上运行
- 的Apache 2.2.20
- RVM 1.10.2
- 红宝石1.9.3p0
- 的Rails 3.1.3
推荐答案
此问题现已解决,但问题本身的原因还不完全清楚。
This issue is resolved now, though the the cause of the problem itself isn't entirely clear.
我与Apache和放一些奇怪的配置问题;乘客(又名ModRails)。两个模块存在:一个似乎来包装与Apache和一个我通过获得乘客安装-Apache2的模块
(?)。当我指着pre-安装了一个,我有这个记录问题。当我指着一个接部署乘客安装-Apache2的模块
,我有一个完全不同的问题,即旅客将与段错误崩溃(见我在ServerFault <后href=\"http://serverfault.com/questions/351651/modrails-for-apache2-setup-failing-to-load/351927\">here.)
I had some weird configuration issues with Apache & Passenger (a.k.a. ModRails). Two modules existed: one that appeared to come packaged with Apache(?) and one I obtained via passenger-install-apache2-module
. When I pointed to the pre-installed one, I had this logging issue. When I pointed to the one deployed by passenger-install-apache2-module
, I had a completely different issue where Passenger would crash with a segfault (see my post on ServerFault here.)
在年底,我彻底消灭我的服务器,并在重新安装完成从基本的Ubuntu AMI一切全新安装(在Amazon EC2上运行使这个很容易做到。),我跑乘客请在安装Apache2的模块
和配置Apache来加载由它部署的模块。这一次,该模块没有崩溃,反而出现日志错误。我设置行chmod 755
在我的Rails应用程序的根目录下,确信的production.log存在,它至少有搭配chmod 0666
特权。瞧,问题消失了。
In the end, I completely wiped my server and performed a clean install of everything from the base Ubuntu AMI (running on Amazon EC2 made this easy enough.) Upon reinstalling, I ran passenger-install-apache2-module
and configured Apache to load the module deployed by it. This time, the module didn't crash, but the log error appeared. I set chmod 755
on the root of my Rails application, made sure the production.log existed and that it had at least chmod 0666
privileges. And voila, problem gone.
TL; DR 做了全新安装,确保我用的是最新的客运模块,我的文件权限被设置正确
TL;DR Did a fresh install, made sure I was using the latest Passenger module, and my file permissions were set properly.
这篇关于Ruby on Rails的设置:无法访问日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!