Monday, 14 May 2012

Ruby|Rails|Paperclip - Errno::EACCES (Permission Denied)

I’ve been setting up a new Ruby on Rails web server running Rails 3 and Ruby 1.9.2 with Phusion Passenger, Capistrano, Git and a number of Gems.

The default setup is running under the root user (I intend to change this later but for now I have decided to get it running under root, document it and then re-deploy the site using a dedicated rails user).

It’s interesting that when running as root when I try to upload an image using the Paperclip gem I get the following error in the production.log file:

Errno::EACCES (Permission denied - /home/rails/{sitename}/releases/20110530200425/public/system/avatars):

I knew this was a permissions problem on the symliked system folder but could not work out the correct user to change this folder to.

My fix was:

cd /home/rails/{sitename}/shared
chown -R nobody system

This has solved the problem however I am wondering why I needed to use the nobody user rather than the www-data user that apache is running under. I would be interested if anyone could shed some light on this.

comments powered by Disqus