简体   繁体   English

Chown在我的Web服务器上不起作用

[英]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.

相关问题 我的服务器不工作,但只在电脑上 - My server doesn't work, but only in computers 不明白为什么我的服务器节点不能与 docker 一起工作 - Dont understant why My server Node doesn't work with docker Nodemailer,在本地工作正常,但在我的服务器上不起作用 - Nodemailer, works fine locally but doesn't work on my server Web套接字服务器在带有Node命令的Ubuntu 12.04终端上不起作用(node server.js) - Web Socket Server Doesn't Work On Ubuntu 12.04 Terminal With Node Command (node server.js) 为什么 node.js 服务器不能在我的子域上工作(在 WHM 服务器上使用 cloudflare)? - Why doesn't node.js server work on my subdomain (using cloudflare on WHM server)? Node.js Express服务器无法在其他服务器上运行,但可以在我的机器上运行 - Node.js Express Server doesn't work on a different server, but works on my machine Firebase Web-重置密码不起作用? - Firebase Web - Reset password doesn't work? 我的node.js简单Web服务器无法访问父文件夹 - My node.js simple web server doesn't access parent folder 为什么我的 Node.js express Server 不能在其他设备上运行? - Why doesn't my Node.js express Server work on other devices? 从另一个目录启动时,我的 node.js 服务器不工作 - My node.js server doesn't work when launched from another directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM