Rails 3 + carrierwave + nginx = permission denied

2019-03-29 12:21发布

问题:

I've installed carrierwave gem with rmagick.

I can get it working fine if load thro WEBrick but getting 500 Internal Server Error when trying to use nginx instead.

The nginx error.log says:

2011/08/14 10:06:40 [crit] 760#0: *4247 open() "/usr/local/Cellar/nginx/1.0.4/client_body_temp/0000000033" failed (13: Permission denied), client: 127.0.0.1, server: jewellery.dev, request: "POST /items/28?locale=en HTTP/1.1", host: "jewellery.dev:8080", referrer: "http://jewellery.dev:8080/items/28/edit?locale=en"

Also I've created an file on initializers folder containing:

CarrierWave.configure do |config|
  config.permissions = 0777
end

Am I missing something?

回答1:

This is not related to CarrierWave, Nginx is not being able to write at the folder /usr/local/Cellar/nginx/1.0.4/client_body_temp/ with the temporary uploaded file, which means your Nginx process doesn't have rights on it. Make sure the user that's running nginx can read/write files under this specific path, if you have not changed the configuration, Nginx usually starts it's workers as user nobody so you might give him read/write acces to this folder.

Run the following command:

ps aux | grep "nginx: worker process"

And see which user is running nginx.