Answer a question

I've deployed a Ruby on Rails app successfully and followed the asset pipeline guide to set up asset compilation and compression. It seems I have a cache issue appearing in my server logs.

It seems I have a Permission denied when trying to mkdir a cache folder? What is going on here? How can I solve this?

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'

The tmp folders user/permissions...

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

part of my 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;
        }

Answers

Set a user directive in nginx.conf:

user www-data;

Then update the permissions of your app to be owned by this user:

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

Note: Also be aware that if you are using capistrano or some other deployment system like that, you also have to update that configuration to use this same user now.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐