Nginx執行php,顯示“No input file specified. ”的處理方法
- 修訂歷史History:
2011.05.29 初稿,僅記錄
- 系統: Ubuntu 10.04
- 軟體: Nginx 0.7.65 | PHP 5.2.10
使用apt-get install nginx和php-cgi
配置好nginx和php,如果配置的請看網上教程,很多。
在/var/www/nginx-default中放上一份phpinfo.php,使用
http://localhost/phpinfo.info |
訪問,結果報錯,顯示 “No input file specified”
【不良現狀】
尋找原因,發現這是一個灰常普遍的問題,處理方法大異其趣!
現存的各種方案,是讓你把nginx站點配置檔案中的這一句話hardcode起來的(真想罵人):
# 即把fastcgi_param指令的SCRIPT_FILENAME項 從動態值改為fixed值,如: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 修改為 fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name; |
另外還有一種是修改php.ini中的什麼
cgi.fix_pathinfo=1 doc_root= |
請注意!!以上這些都是非常不良的改動!
【問題原因】
導致“No input file specified. ”這個問題的原因,是因為nginx的配置不正確,從而導致CGI獲取引數錯誤。
簡單來說,是因為$document_root這個變數尚未定義。
Nginx的配置檔案中,
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
而我們也知道,在nginx中,有三級的關係,http > server > location。
如果要在location塊中使用$document_root,需要在上層server塊或http塊中定義了root指令,這樣才能通過繼承關係,在location塊中用$document_root拿到root的值。而定義在別的location塊中的root指令的值,是一個區域性變數,其值無法在匹配php的這個location塊中被獲取。
因此,解決這個問題的辦法,是把"/" location塊中的root上提到server。
或者,在php的location塊中,重新定義root。
即可。
具體配置是這樣的
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
出處:http://blog.163.com/cobyeah@126/blog/static/140137653201142945054441/
相關文章
- No input file specified.
- 記:痛苦的排錯之” No input file specified.“
- 使用url()後出現No input file specified.
- apache PHP 隱藏 index.php 報錯 No input file specified. 解決辦法ApachePHPIndex
- apache 與 Nginx 隱藏 index.php 報錯 No input file specified. 解決辦法 設定偽靜態ApacheNginxIndexPHP
- Web 伺服器顯示 no input file specifiedWeb伺服器
- 網站執行PHP出現No input file specified 的解決辦法網站PHP
- plsql顯示韓文亂碼的處理方法SQL
- 處理input file限制只能拍照不能選相簿
- nginx+PHP-fpm 配置後頁面顯示空白的解決方法NginxPHP
- 在 apache 中重寫規則不生效的問題 [No input file specified.] 解決Apache
- 資料顯示62%的網站仍然執行PHP 5網站PHP
- php 與 nginx 的兩種處理方式PHPNginx
- Nginx 與 PHP 的執行機制NginxPHP
- No input file specified 解決方法
- win10瀏覽器執行緩慢顯示正在處理怎麼辦Win10瀏覽器
- 系統中資料顯示進行脫敏處理
- win10行動硬碟我的電腦無顯示怎麼辦 win10行動硬碟電腦不顯示處理方法Win10硬碟
- bc搭建資料夾顯示特殊html字元處理方法HTML字元
- awr報告中顯示enq: TM - contention 處理方法ENQ
- php事務處理方法PHP
- php執行的時候報File size limit exceededPHPMIT
- linux下面顯示所有正在執行的執行緒Linux執行緒
- 執行 PHP artisan queue:work 一直 processing 非正常執行處理PHP
- 記錄一次通過homestead配置多站點不起作用的坑--No input file specified.
- nginx+php執行請求的工作原理NginxPHP
- jQuery 顯示 input 輸入的密碼!jQuery密碼
- 顯示oracle執行時間Oracle
- no input file specified 三種解決方法
- idea執行時預設顯示自己建立的jsp方法IdeaJS
- 顯示網路圖片變形的處理
- 【JavaScript】拖拽圖片檔案顯示縮圖 + div點選模擬 input[type=file]JavaScript
- win10圖示錯誤顯示怎麼改回來_win10電腦圖示顯示錯誤處理方法Win10
- win10桌面桌布無法顯示如何解決_win10桌面背景不顯示的處理方法Win10
- Nginx+Php-fpm 執行原理詳解NginxPHP
- Nginx %00空位元組執行php漏洞NginxPHP
- input 的placeholder不顯示如何解決
- IO處理執行緒執行緒