I’m deploying my app to my new Rails 3.1 server with capistrano.
When I’m trying to browse the page, I get a rails error.
While looking in the error.log, this is what I see:
ActionView::Template::Error (Permission denied - /var/www/episodecalendar/production/releases/20111227204950/tmp/cache/55B):
32: </div>
33: <div id="footer">
34: <div id="footer_content">
35: <% cache("footer") do %>
36: <%= render :partial => "partials/footer" %>
37: <% end %>
38: </div>
app/views/layouts/application.html.erb:35:in `_app_views_layouts_application_html_erb___3483336897212790867_58416560'
Obviously the files in the /tmp folder don’t have the “correct” permissions. Example:
root@Ubuntu:/var/www/episodecalendar/staging/current/tmp/cache/assets/C0C/690# ls -la
total 12K
drwxr-xr-x 2 root root 4.0K 2011-12-27 21:33 .
drwxr-xr-x 3 root root 4.0K 2011-12-27 21:33 ..
-rw-r--r-- 1 root root 2.6K 2011-12-27 21:33 sprockets%2F31007441199035e09c0c45c33930cf06
The only way to fix it, is a chmod 777 tmp/ -R, and then the site loads straight away.
I could put the chmod fix in a capistrano recipe, but that seems like an ugly hack.
Why doesn’t the /tmp folder have the “correct” permission after a deploy, and how can I fix it?
Rather than permitting everyone access to all files and folders within tmp
chmod 777 -R tmp/, you may want to consider ensuring that/var/www/episodecalendar/staging/is recursively chown’d (chown -R user:group /var/www/episodecalendar/staging) by whatever user requires access to run the web server.I’d recommend creating a separate
deploy@Ubuntuuser so that (unlike root) permissions issues become apparent quickly.