怎麼修: FastCGI sent in stderr – PHP message: PHP Warning: move_uploaded_file

PHP Warning: move_uploaded_file 是一個典型的 Web 服務器錯誤 NGINX 並在我們要將文件上傳到服務器時出現。 大多數時候,當我們必須上傳證書或其他不屬於 “Media”,我們在 CMS 管理界面中看不到錯誤。

在更具體的形式中,錯誤 “PHP Warning: move_uploaded_file” 我們發現它在 error.log 作為:

FastCGI sent in stderr: "PHP message: PHP Warning:  move_uploaded_file(/srv/www/domain.test/public/file.file): failed to open stream: Permission denied in /srv/www/domain.test/public/script.php on line 748 PHP message: PHP Warning:  move_uploaded_file(): Unable to move '/tmp/phpqAVtWy'

為什麼會發生錯誤 PHP Warning: move_uploaded_file 以及我們如何解決它

正如我上面所說,當我們嘗試將文件上傳到 Web 服務器時會發生錯誤。

FastCGI sent in stderr”對於具有 PHP-FPM 和 NGINX 作為網絡軟件。 所以問題出在上傳文件的腳本的關係中。

move_uploaded_file(): Unable to move”非常清楚地告訴我們,這些文件無法通過執行操作的腳本上傳並移動到 Web 服務器上的另一個文件夾。

解決此錯誤 PHP 解決起來非常簡單,在服務器上設置正確的權限,包括執行腳本,最可能的用戶:nginx 沒有訪問權限,以及目標文件夾。

如果網站文件不屬於用戶,就像在 cPanel 上一樣, VestaCP 或其他託管管理平台,那麼幾乎可以肯定的解決方案是讓 nginx 用戶訪問上傳文件夾和腳本。

對於上面的代碼示例,我們將在 SSH 中執行以下命令:

chown -R nginx:nginx /srv/www/domain.test/public/
chmod g+w file.file

我們恢復上傳,一切都應該正常工作 move_uploaded_file(): Unable to move.

如果仍有問題,可以在本教程的評論中解決。

對技術充滿熱情,我很高興寫 StealthSettings.com 自 2006 年起。我在作業系統方面擁有豐富的經驗: macOS, Windows 對 Linux,而且還包括程式語言和部落格平台(WordPress)和線上商店(WooCommerce、Magento、PrestaShop)。

如何 » 教程和 IT 新聞 » 如何修復:FastCGI 發送到 stderr – PHP 消息: PHP Warning: 移動上傳文件

1 想到“如何修復: FastCGI sent in stderr – PHP message: PHP Warning: move_uploaded_file”

  1. 你好,
    請參閱有關 [move_upload_file] 的文章。
    Il se trouve que je suis confonn avec ce problème et que je cherche depuis moult mois de m'en sortir sans succès。
    我有一個個人網站,其中有一個 Formaire.html 頁面,該頁面僅部分起作用,要知道:無法打開流程等...並且將它們移動到“上傳”中是安全的。
    Je suis retraité des Arts graphiques, typographe à 13 ans, puis monteur offset, infographiste, webmaster, bref j'ai 84 ans retraité et je suis toujours et encore passionné par mon métier.
    我已經開發了 html 和 JavaScript,我正在使用 PHP。
    我和我的同事 anciens combattant d'Algérie, de petites sorties et realise des "reportages" 放在我的網站上 Perso à dispo pour ceux qui sont intéressés; donc,我希望收到文檔汽車 je ne pas tout faire moi même pour illustrer mes propos,d'où l'idée du Formulaire et traitement PHP。
    我用“Dreamweaver CC2020”版本創建了我的網站 Mac hébergé chez moi sur un serveur Synology “Ngnix” DMS v. 7.1 – PHP 8(可能是 php 7.2、php 7.3、php 7.4)。 默認證書(無 IP):TrustCor DV CA – G2 RSA
    該表單適用於“文本”字段,但拒絕“媒體”字段。
    如果需要,您可以連接到上面的 URL,單擊小雕像,因為我不必激活 html“返回”,您可以在 PHP 頁面中可視化結果。 (我已經為媒體分配了 10 Mb 和 20 Mb)。
    Et si je vous suis bien, le soucis viendrait du “FastCGI” des serveurs Nginx PHP-TPM ce qui est mon cas, alors dans le volet TPM, il existe bien moult cases à cocher ou décocher, mais les quelles?
    我注意到 SSH 命令:
    chown -R nginx:nginx /srv/www/domain.test/public/
    chmod g+w 文件.文件
    Mais conviendra-t-telle à mon serveur?
    謝謝您的寶貴意見

    回复
發表評論