权限被拒绝通过FTP用户上传新的PHP文件

问题描述:

当我尝试使用vsftpd的到/ var/www会上传PHP文件/并访问从网络服务器上的文件我得到这个错误,权限被拒绝通过FTP用户上传新的PHP文件

Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

Fatal error: Unknown: Failed opening required '/var/www/.../.../public_html/d.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0

我试图CHOWN -R www-data:www-data/var/www之后,错误得到了解决,但每次我上传一个新文件时都必须做同样的事情,是否有解决所有新文件的问题?

+0

您应该能够通过修改设置上传文件的默认权限的'vsftpd.conf'尝试加入'file_open_mode = 0777'和 'local_umask = 022'。第一个设置指定上传文件的默认权限。您也可以检出配置文件的手册页:https://security.appspot.com/vsftpd/vsftpd_conf.html – Cyclonecode

+0

@Cyclonecode我将两个都添加到vsftpd.conf并重新启动vsftpd,但仍然遇到与新文件相同的问题。 – Vedbex

+0

你确定你正在修改正确的配置文件吗? – Cyclonecode

最好的方法是将ACL应用于相关目录。

This will set the default so new files and folders are given the ACL, this says that the group of www-data will have read,write,execute permissions by default on all files/folders from /var/www recursively

sudo setfacl -Rdm g:www-data:rwx /var/www 

This will set the ACL for existing files and folders, this says that the group of www-data will have read,write,execute from /var/www recursively for existing files and folders

sudo setfacl -Rm g:www-data:rwx /var/www 
+0

为什么选择投票? – Augwa