Rails生产服务器缓存Nginx拒绝权限

时间:2012-02-13 05:26:30

标签: ruby-on-rails caching permissions nginx production

我已成功部署了Ruby on Rails应用程序,并按照资产管道指南设置资产编译和压缩。我的服务器日志中似乎出现了缓存问题。

在尝试使用mkdir缓存文件夹时,似乎我的权限被拒绝了?这里发生了什么?我该如何解决这个问题?

nginx / logs error.log ...

cache: [GET /assets/grid.png] miss
cache: [GET /] miss
cache error: Permission denied - /var/www/redmeetsblue/releases/20120212234112/tmp/cache/B27
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir'
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir'
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/fileutils.rb:221:in `block (2 levels) in mkdir_p'
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/fileutils.rb:219:in `reverse_each'
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/fileutils.rb:219:in `block in mkdir_p'
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/fileutils.rb:205:in `each'
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/fileutils.rb:205:in `mkdir_p'

tmp文件夹用户/权限...

ls -alh /var/www/redmeetsblue/current/tmp
total 12K
drwxr-xr-x  3 root root 4.0K 2012-02-12 18:43 .
drwxrwxr-x 13 root root 4.0K 2012-02-12 18:41 ..
drwxr-xr-x  3 root root 4.0K 2012-02-12 18:43 cache
lrwxrwxrwx  1 root root   33 2012-02-12 18:41 pids -> /var/www/redmeetsblue/shared/pids
-rw-r--r--  1 root root    0 2012-02-12 18:41 restart.txt

我的nginx.conf的一部分...

http {
    passenger_root /usr/local/rvm/gems/ruby-1.9.3-p0/gems/passenger-3.0.11;
    passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-p0/ruby;

    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen            80;
        server_name       173.255.210.212;
        root              /var/www/redmeetsblue/current/public/;
        passenger_enabled on;
      }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

1 个答案:

答案 0 :(得分:7)

user中设置nginx.conf指令:

user www-data;

然后更新此用户拥有的应用的权限:

sudo chown -R www-data /var/www/redmeetsblue

注意:另请注意,如果您使用capistrano或其他类似的部署系统,则还必须更新该配置以立即使用此用户。