Rails 3.1 Errno::EACCES Permission Denied

这一生的挚爱 提交于 2019-11-27 21:15:00

问题


Rails 3.1 Passenger on Apache Development environment When I go to access the index (i.e. GET) for a route I get:

Errno::EACCES in Crb_agendas#index

Showing /var/www/crbagenda/app/views/layouts/application.html.erb where line #5 raised:

Permission denied - /var/www/crbagenda/tmp/cache/assets/E2C

Extracted source (around line #5):

2: <html>
3: <head>
4:   <title>CrbAgendas</title>
5:   <%= stylesheet_link_tag "application" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>

Rails.root: /var/www/crbagenda

When I go to the path mentioned (/var/www/crbagenda/tmp/cache/assets/E2C) there is no E2C folder and root (what apache is running as) owns the assets dir... not sure what I did wrong here.... or what else I could show to help.


回答1:


I found this post when I encountered this error and running chmod 777 is not the solution here.

You need to do some research on how to enable group permissions and configure apaches settings appropriately. Here is a Stack Exchange thread that details this rather well and contains useful links. Make sure apache has read, write and execute access to the appropriate directories but don't simply let ANYONE modify the directory. Locate your systems apache group and run chown and chmod -g+[What permissions apache needs goes here] I would suggest not running this with the -R option and to actively look into which permission apache needs for specific directories. Link to Stack Exchange thread regarding apache permissions and permissions in general




回答2:


Update: Yeah this answer came from ignorance and then seemed to gain traction. Anyway, the real answer can be found in Austen Tomek's answer

Hacked around this by doing chmod 777 on the tmp directory so I am guessing it is my ignorance on the user/permissions settings.




回答3:


I deleted the tmp folder completely, that worked for me. It just gets regenerated by the web server.




回答4:


For me it was useful:

sudo chown -R username app_path



回答5:


Just run chown on project folder

chown -R www-data /var/www/



回答6:


Im using windows vs code with a ubuntu subsystem as the terminal.

I had to move my project folder from the ubuntu sub system area to the windows area.. so everytime I run stuff with ubuntu I have to type cd /mnt/c/projects/my_app

it seems to allow the apps to run and the db/ server stuff to operate alright..

Rhys




回答7:


Thanks to the posts above, I got to solve my own problem too. Personally, an important folder was labeled "Hidden" (follow the ERROR path Error: Permission denied - .../_netrc (Errno::EACCES) As soon as I right-clicked and set its folder options to NOT HIDDEN, then everything worked fine!




回答8:


On windows just open your cmd as Administrator and execute your gem install "lib" command




回答9:


In my case changing rights nor ownership of the directory didn't help (well it was necessary). Turned out that Selinux kicked in (by default enabled in Fedora) and disabling was the cure:

$ sudo setenforce 0

To make the change permanent one has to change the settings in the /etc/selinux/config file:

SELINUX=disabled


来源:https://stackoverflow.com/questions/8127849/rails-3-1-errnoeacces-permission-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!