[英]Chown doesn't work on my web server
I get an issue using sudo chown -R www-data:www-data /var/www
on my web server (ubuntu 14.04). 我在Web服务器(ubuntu 14.04)上使用
sudo chown -R www-data:www-data /var/www
时遇到问题。
My NodeJS application is using the fs
module and when I want to edit a json
file it works only if I do a sudo chmod 0777 myfile
, with the chown
it doesn't work... 我的应用程序的NodeJS使用
fs
模块,当我想编辑一个json
文件,如果我做了它只能sudo chmod 0777 myfile
,与chown
它不工作...
Any ideas? 有任何想法吗?
The chown command made the user www-data
the owner of the files in /var/www
, which means that to get full (r/w) access to those files you either have to run your Node app as that user as well ( sudo -u www-data 'pm2 start ...'
), you have to adjust the permissions on the file(s) so that your regular user id can write them (like you found out after chmodding them to 0777), or you have to chown the files to your regular user id (but there's probably a reason why you chowned them to www-data
in the first place). chown命令使用户
www-data
成为/var/www
文件的所有者,这意味着要完全(r / w)访问这些文件,您还必须以该用户身份运行Node应用程序( sudo -u www-data 'pm2 start ...'
),您必须调整文件的权限,以便您的常规用户ID可以写入它们(例如将它们切入0777后发现的内容),或者将文件整理为常规用户ID(但首先将其整理为www-data
可能是有原因的)。
I would opt for the first solution (using su
). 我会选择第一个解决方案(使用
su
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.