Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 系統與 PHP 常見錯誤匯總:從 DNS 解析到權限問題完整解析

編輯:Linux 教學

整理實務中高頻出現的 Linux 系統與 PHP 應用錯誤,涵蓋網路、權限、版本相容、資源限制等核心場景,附帶原因分析與解決方案。

網路與 DNS 解析類

fsockopen(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

原因:伺服器無法解析域名,DNS 服務異常或 /etc/resolv.conf 配置錯誤。
解決:檢查 DNS 設定、防火牆是否阻擋 53 端口、嘗試 dig/nslookup 驗證解析。

Fatal error: Maximum execution time of 30 seconds exceeded

原因:安裝程式需連外部認證伺服器(80 端口),DNS 不通或防火牆阻攔;或 Apache/MySQL 有僵屍進程。
解決:檢查 DNS 與外網連通性、重啟 Apache/MySQL、調大 max_execution_time。

文件與路徑類

Warning: main(...): failed to open stream: No such file or directory

原因:傳輸過程文件損壞或遺漏。
解決:重新完整上傳發布包,核對文件完整性(md5sum)。

安裝時出現白屏

原因:PHP 錯誤未顯示、PHP 版本與程式包不匹配(CMSware 2.5+ 分 PHP4/PHP5 包)、目錄權限錯誤。
解決:php.ini 設 display_errors = On、確認 PHP 版本對應、修正目錄寫入權限。

權限與安全模式類

Warning: touch(): Utime failed: Operation not permitted

原因:PHP 運行於 Safe Mode 限制。
解決:關閉 safe_mode 或統一 FTP 與 Web 進程用戶 UID/GID。

Warning: mkdir(): SAFE MODE Restriction in effect... uid 622 not allowed to access ... owned by uid 48

原因:Safe Mode 限制跨用戶目錄操作。
解決:php.ini 設 safe_mode = Off,或調整目錄擁有者一致。

版本相容類

Fatal error: Incompatible file format: The encoded file has format major ID 2... encoded by Zend Encoder for php 5... cannot be run on php 4

原因:PHP4 環境強行運行 PHP5 加密程式包。
解決:嚴格匹配 PHP 版本與發布包(PHP4 用 PHP4 包,PHP5 用 PHP5 包)。

Warning: Unexpected character in input: '\' (ASCII=92)... Parse error: syntax error

原因:同樣是 PHP 版本與程式包不匹配。
解決:更換對應版本發布包。

虛擬主機特有問題

刪除文件失敗,屬性 777 也無效

原因:.htaccess 隱藏文件阻礙刪除。
解決:FTP 客戶端開啟「顯示隱藏文件」,刪除 .htaccess 後再操作。

排查通用建議

  1. 優先開啟 display_errors 獲取具體錯誤堆疊。
  2. 核對 PHP 版本、擴展模組(如 Zend Optimizer、pdo_mysql)是否滿足需求。
  3. 檢查關鍵目錄(cache、uploads、data)讀寫權限(通常 755/777)。
  4. 遇到網路相關錯誤,先 ping/telnet 驗證連通性與 DNS。

系統化掌握這些高頻錯誤,能大幅縮短故障定位時間,提升運維效率。

Copyright © Windows教程網 All Rights Reserved