我的问题是apache无法通过PHP编写文件(例如,编写csv文件)--我必须将文件权限更改为777,而且它可以工作,但安全性很差。我试图使用足够的权限来编写,可能是664。哪里出了问题?
Apache以apache的形式运行,而group也是apache。/var/www/html中的所有文件都归root所有,组为web-content
我可以登录到FTP客户端和读写文件到/var/www/html没有任何问题。
我创建了一个名为intranet的ftp用户,在这里我所做的是:
groupadd web-content
usermod -G web-content intranet
chown root:web-content /var/www/html
chmod o+rx /var/www/html
find /var/www/html -type f -exec chmod 0664 {} \;
find /var/www/html -type d -exec chmod 0775 {} \;ls -la /var/www/
drwxrwxr-x. 4 root web-content 4.0K Sep 6 16:09 html当我在FTP上上传新文件时。
ls -la /var/www/intranet/
-rw-r--r--. 1 intranet intranet 0 Sep 6 17:42 test发布于 2013-09-06 16:29:09
7 - owner bits, read/write/execute
5 - group bits, read/execute
5 - everyone else bits, read/execute因为文件是755,所以只有所有者有写权限。您已经将apache作为apache运行,并且该文件由root拥有,因此所有者不匹配,并且您最终没有写权限。
您可能希望将该文件切换到apache:web-content或至少root:web-content,然后将文件575改为,这样组权限就匹配了。
https://stackoverflow.com/questions/18662350
复制相似问题