Ruby on Rails Setup: Unable to access log file

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

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

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:

  • 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 , set chmod 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
    
  • "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>
    
  • The owner of "config.ru" and "configs/environment.rb" is www-data

  • 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: 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...)

    Some environment settings of mine:

  • Ubuntu 11.10 running on Amazon EC2
  • Apache 2.2.20
  • RVM 1.10.2
  • Ruby 1.9.3p0
  • Rails 3.1.3

  • This issue is resolved now, though the the cause of the problem itself isn't entirely clear.

    I had some weird configuration issues with Apache & Passenger (aka 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.)

    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 Did a fresh install, made sure I was using the latest Passenger module, and my file permissions were set properly.

    链接地址: http://www.djcxy.com/p/63562.html

    上一篇: Rails I18n验证弃用警告

    下一篇: Ruby on Rails安装程序:无法访问日志文件