日志文件不被写入(客) [英] Log files not being written to (Passenger)

查看:201
本文介绍了日志文件不被写入(客)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在当地,我的应用程序运行正常并写入其日志。

Locally, my app runs fine on and writes to its logs.

我的生产服务器运行的是与Apache服务器上运行CentOS的乘客。当试图调试,我发现我的日志文件没有被写入。我所做的第一件事就是搭配chmod 0666他们,当我发现没有工作,我看着我的Apache日志。我发现这一点:Rails的错误:无法访问日志文件。请确保/var/www/vhosts/mysite.com/rails/exp/releases/20091124020342/log/production.log存在,并且搭配chmod 0666的日志级别已经提升到WARN和输出定向到STDERR直到问题是固定的。

My production server is running CentOS with an Apache server running Passenger. When trying to debug, I noticed my log files were not being written to. First thing I did was chmod 0666 them, and when I found out that didn't work I looked at my apache log. I found this: Rails Error: Unable to access log file. Please ensure that /var/www/vhosts/mysite.com/rails/exp/releases/20091124020342/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.

(注:我与Capistrano的部署)

(Note: I am deploying with capistrano)

反正我用Google搜索了一圈,发现人说,这是一个SELinux的问题,所以我看着乘客的文档,发现这个:<一href=\"http://www.modrails.com/documentation/Users%20guide.html#%5Fmy%5Frails%5Fapplication%5F8217%5Fs%5Flog%5Ffile%5Fis%5Fnot%5Fbeing%5Fwritten%5Fto\" rel=\"nofollow\">http://www.modrails.com/documentation/Users%20guide.html#%5Fmy%5Frails%5Fapplication%5F8217%5Fs%5Flog%5Ffile%5Fis%5Fnot%5Fbeing%5Fwritten%5Fto

Anyway, I Googled around and found people saying it's an SELinux issue, so I looked on passenger's docs and found this: http://www.modrails.com/documentation/Users%20guide.html#%5Fmy%5Frails%5Fapplication%5F8217%5Fs%5Flog%5Ffile%5Fis%5Fnot%5Fbeing%5Fwritten%5Fto

这基本上说,做到这一点:chcon这个-R -h -t httpd_sys_content_t /路径/要/你/导轨/应用

which basically says do this: chcon -R -h -t httpd_sys_content_t /path/to/your/rails/app

然而,当我填写正确的路径获得:不支持操作

However, when I fill in the proper path I get: Operation not supported.

pretty难倒...任何想法?

Pretty stumped...any ideas?

推荐答案

我遇到同样的问题,我的Ubuntu的服务器10.x中。这是我学过的故障排除。

I ran into the same issue with my ubuntu 10.x server. Here's what I learned while troubleshooting.


  • 正如前面提到的previously并在文档,客运运行轨道红宝石过程作为到config / environment.rb文件的所有者。除非你做了一些特别的东西,这通常是同整个Rails应用程序目录的所有者。在一个Capistrano的部署的情况下,这是Capistrano的用户。

  • 如果environment.rb文件是由根(很可能是因为您正在部署根)拥有客运运行轨道的过程是没有人

您可以看到用户的进程运行作为通过top命令(或任何其它技术)。

You can see which user the processes are run as via the top command (or any number of other techniques).

在这两种情况下 - 我的happend是后者 - 如果导轨进程无法写入日志文件,没有在日志(杜)显示出来。 Rails会忽略这个权限被拒绝的错误,并尝试处理请求作为正常。

In either case -- mine happend to be the latter -- if the rails processes cannot write to the log files, nothing shows up in the logs (duh). Rails will ignore this permission denied error and try to process the requests as normally.

解决方案是保证轨道红宝石进程正在运行为拥有你的Rails的部署,到config / environment.rb文件和日志目录和文件的用户。

The solution is to ensure that the rails ruby processes are running as the same user that owns your rails deployment, config/environment.rb file and the logs directory and files.

这可以是deplyment的配置步骤执行chown有问题的文件和目录,或配置Apache并告诉它运行红宝石过程作为一个特定的用户(比如,根,而不是人的)。显然是不建议作为root运行,但如果你这样做,不管是什么原因,以及需要看到铁轨日志正确写入,您可以通过添加这样做以下

This can be either deplyment configuration step to chown the files and directories in question or configuring apache and telling it to run the ruby process as a specific user (say, root instead of nobody). Running as root is obviously not recommended, but if you are doing that for whatever reasons, and need to see rails logs properly written to, you can do this by adding the following

# in /etc/apache2/apache2.conf
PassengerDefaultUser root 

如果你不是作为root部署(这是另一台服务器我有这种情况),典型的方案应该是Rails应用程序目录是由非root用户拥有,乘客应运行轨道流程作为同一用户。所有的一切都应该只是工作。

If you are not deploying as root (which is the case on another server I have), the typical scenario should be that the rails app directory is owned by that non-root-user, and passenger should run the rails processes as that same user. And everything should just work.

[1] <一个href=\"http://www.modrails.com/documentation/Users%20guide%20Apache.html#_the_rails_application_reports_that_it_8217_s_unable_to_start_because_of_a_permission_error\" rel=\"nofollow\">http://www.modrails.com/documentation/Users%20guide%20Apache.html#_the_rails_application_reports_that_it_8217_s_unable_to_start_because_of_a_permission_error

这篇关于日志文件不被写入(客)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆