[英]Rails / Carrierwave / GIT / nginx / Capistrano - can't create a directory in git releases folder
I'm using carrierwave in a rails app to upload files. 我在Rails应用程序中使用carrierwave来上传文件。 It works fine on my development environment, but on my production VM (Ubuntu), I'm getting this error:
它在我的开发环境上正常工作,但是在生产VM(Ubuntu)上,出现此错误:
An Errno::EACCES occurred in users#update: 用户#update中发生了Errno :: EACCES:
Permission denied - /home/yards/apps/yardsapp/releases/20130616143623/public/uploads/tmp/20130616-1438-14186-3184
/usr/local/lib/ruby/1.9.1/fileutils.rb:244:in `mkdir'
I'm pretty sure I understand what is going on, but I can't seem to figure out a fix. 我很确定我了解发生了什么,但似乎无法找出解决办法。 My capistrano deploy.rb is set up with the user as root.
我的capistrano deploy.rb是用root用户设置的。 So when it creates the new release folder on a deploy, the access rights are for root (I think).
因此,当它在部署上创建新的发行文件夹时,访问权限是针对根的(我认为)。
Then when I try to upload a file, I get that error because nginx is trying to execute a mkdir as www-data. 然后,当我尝试上传文件时,出现此错误,因为nginx试图将mkdir作为www-data执行。
I could chown the folder after the deploy and it works...but then another deploy creates another new directory with owner set to root as default. 我可以在部署后将文件夹扔掉,它可以工作...但是,然后另一次部署创建了另一个新目录,所有者默认设置为root。
At least I think this is what is going on. 至少我认为这是正在发生的事情。 Does anyone have any ideas on how I should be doing this?
有人对我应该如何做有任何想法吗?
Run your deployment as www-data
. 作为
www-data
运行您的部署。 You might need to adjust the authorized_keys
file for the www-data
user as well to be able to connect. 您可能还需要调整
www-data
用户的authorized_keys
文件才能连接。
To fastest way would be to copy over your authorized_keys
file for whatever user you are using at the moment (assuming you are root): 最快的方法是为当前正在使用的任何用户(假设您是root用户)复制您的
authorized_keys
文件:
mkdir $WWW_DATA_HOME/.ssh
cp ~/.ssh/authorized_keys $WWW_DATA_HOME/.ssh/authorized_keys
chown www-data:www-data $WWW_DATA_HOME/.ssh/authorized_keys
You might also need to change the shell for the www-data
user to log in to it: 您可能还需要更改
www-data
用户的外壳程序才能登录到它:
chsh -s /bin/bash www-data
Now you should be able to do 现在您应该可以
ssh www-data@your-host.tld
and log in. 并登录。
What this came down to was an improper Capistrano configuration. 这归结为Capistrano配置不当。 I followed the capistrano docs correctly (and made a 'deployer' user, same thing as the www-data as suggested above) and I have capistrano working like a charm.
我正确地遵循了capistrano文档(并使其成为一个“部署者”用户,与上面建议的www-data相同),并且我使capistrano像魅力一样工作。 Also upgraded to Capistrano 3.
还升级到Capistrano 3。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.