简体   繁体   中英

Rails Permission denied @ dir_s_mkdir

When i am trying to Upload a File i am getting the following error on the server

Permission denied @ dir_s_mkdir - /var/www/noise/public/uploads/tmp/1422949577-24950-7745

I tried to give 777 permission to the public folder. Still am getting the error

root@99atoms-staging:/var/www/noise# sudo chmod 777 /var/www/noise/
root@99atoms-staging:/var/www/noise# stat -c %a /var/www/noise/public
755
root@99atoms-staging:/var/www/noise# sudo chmod 777 /var/www/noise/public
root@99atoms-staging:/var/www/noise# stat -c %a /var/www/noise/public
777

Server Log

App 24927 stderr:
App 24927 stderr:
App 24927 stderr: Started POST "/companies" for 122.172.197.148 at 2015-02-03 02:55:17 -0500
App 24927 stderr: Processing by CompaniesController#create as HTML
App 24927 stderr:   Parameters: {"utf8"=>"?^?^?", "authenticity_token"=>"CNSqDFRAYxle0NpVIPqGXPYWMWkoYGRLDeqgmzwjiUE=", "company"=>{"name"=>"Mink7", "display_photo"=>#<ActionD$
App 24927 stderr:   ^[[1m^[[36mUser Load (0.2ms)^[[0m  ^[[1mSELECT  `users`.* FROM `users`  WHERE `users`.`id` = 1  ORDER BY `users`.`id` ASC LIMIT 1^[[0m
App 24927 stderr:   ^[[1m^[[35mCompanyMember Load (0.1ms)^[[0m  SELECT `company_members`.* FROM `company_members`  WHERE `company_members`.`status` IN (0, 1, 3) AND `company_m$
App 24927 stderr:   ^[[1m^[[36mCompany Load (0.1ms)^[[0m  ^[[1mSELECT `companies`.* FROM `companies`  WHERE 1=0^[[0m
App 24927 stderr: Completed 500 Internal Server Error in 6ms
App 24927 stderr:
App 24927 stderr: Errno::EACCES (Permission denied @ dir_s_mkdir - /var/www/noise/public/uploads/tmp/1422950117-24950-9686):
App 24927 stderr:   app/controllers/companies_controller.rb:33:in `create'
App 24927 stderr:
App 24927 stderr:
App 24927 stderr:   Rendered /usr/local/rvm/gems/ruby-2.2.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/_source.erb (1.3ms)
App 24927 stderr:   Rendered /usr/local/rvm/gems/ruby-2.2.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.9ms)
App 24927 stderr:   Rendered /usr/local/rvm/gems/ruby-2.2.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.9ms)
App 24927 stderr:   Rendered /usr/local/rvm/gems/ruby-2.2.0/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (19.1m$

We need to grant permission to access the required directory for the system root user

sudo chmod 777 -R your_project_directory_to_be_access

In your case you can use:

sudo chmod 777 -R /var/www/noise/public

For security reasons, just keep in your mind:

chmod 777 gives everybody read, write and execute rights which for most problems is definitively too much.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM