I have a rails app on an Ubuntu server. In my Apache config I have set the user and group to www-data. I want my rails app to write to a file. I have set the file permissions as follows:
-rw-rw-r-- 1 www-data www-data 0 Jun 5 22:35 notify_list.txt
Seems like rails should be able to write because the permissions are correct. But I keep getting permission denied. What are possible causes of this?
Thanks!
Best Answer
Are you running your Rails application under Apache via mod_rails/passenger?
You may need to set the user that passenger runs the Rails application with "PassengerDefaultUser". Since you mention www-data, I'm assuming an ubuntu or debian server, so this would probably be a separate vhost file in /etc/apache2/sites-available. Add the line:
To the correct vhost file. If you don't know which file, run "
sudo apache2 -S
" to show the available vhosts in the configuration and pick the file that matches the hostname you access the Rails app.