2017-02-18 86 views
2

當我嘗試使用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

回答

-1

最好的方法是將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