如题所述
ããæå¼ä¸ä¸ªé¡µé¢<?php phpinfo(); ?> ç¶åå¨æ¸¸è§å¨ä¸è¿è¡ï¼é¡µé¢æ示 No input file specified. FastCGI模å¼ä¸è®¿é®phpæ件æ¶ï¼åºç°No input file specified.é误 æ¥çaccess.log åç°æ¯ 404
ããæå¼ä¸ä¸ªé¡µé¢<?php phpinfo(); ?> ç¶åå¨æ¸¸è§å¨ä¸è¿è¡ï¼é¡µé¢æ示
ããNo input file specified.
ããFastCGI模å¼ä¸è®¿é®phpæ件æ¶ï¼åºç°No input file specified.é误
ããæ¥çaccess.log åç°æ¯ 404
ããåå åæï¼
ãã1ãä»»ä½å¯¹.phpæ件ç请æ±ï¼é½ç®åå°äº¤ç»php-cgiå»å¤çï¼ä½æ²¡æéªè¯è¯¥phpæ件æ¯å¦åå¨ãPHPæ件ä¸åå¨ï¼æ²¡åæ³è¿åæ®éç404é误ï¼å®è¿å ä¸ä¸ª404,并带ä¸ä¸å¥âNo input file specifiedâ
ãã2ãè¿å¯è½è· è·¯å¾æè æéæå ³ç³»ï¼æè SCRIPT_FILENAME åé没æ被æ£ç¡®ç设置(è¿å¨nginxæ¯æ常è§çåå )
ãã1)å¦æhtmlä¹åºç°404é误ï¼é£ä¹å°±æ¯document root 设置çæé®é¢
ãã2)æ£æ¥èæ¬æ件çæé, å¯è½PHPæè web serverä¸è½è¯»åå®
ãã3)SCRIPT_FILENAME设置é误
ããç½ä¸ç解å³æ¹æ³ï¼
ããæ¥éª¤ä¸ï¼ä¿®æ¹nginx主é ç½®æ件nginx.conf
ããé»è®¤å®è£ çnginxé ç½®æ件ä¸å®ä¹fastcgiå¤æ¯ï¼fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
ããå¯ä»¥å°å®æ¹æï¼
ããfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
ããå¿ é¡»ä¿è¯ $document_root å¨é ç½®æ件ä¸ï¼å¨astcgi_param SCRIPT_FILENAMEåé¢è¢«ç¨å°è¿ä¸æ¬¡, åé¢æ解é为ä»ä¹ã
ããæ¥éª¤äºï¼ä¿®æ¹PHPçä½é ç½®æ件php.ini
ããä¿®æ¹/etc/php5/cgi/php.iniä¸cgi.fix_pathinfo=1
ããè¿æ ·ä¹å¯è®©php-cgiæ£å¸¸ä½¿ç¨SCRIPT_FILENAMEè¿ä¸ªåé
ããæ人说ï¼è¿æ ·æ¹ä¹è¡
ããfastcgi_param SCRIPT_NAME /home/gavin/nginx/$fastcgi_script_name;
ãã让æ们ççPHP对è¿ä¸¤ä¸ªåéæ¯æä¹è§£éçå§
ããSCRIPT_NAME
ããSCRIPT_FILENAME
ããæ®è¯´,å¿ é¡»æå®æ£ç¡®çSCRIPT_FILENAME, PHP-CGIä¼å¿½ç¥SCRIPT_NAME(å³ä½¿å®çå¼è®¾ç½®çæ¯æ£ç¡®ç)
ããæè æå®ç¹æ®çphp.ini, 设置doc_root, discard path, fix pathinfoçç
ããscript_filename åªæ¯è¢«ç¨åä¸ç§å¿«æ·æ¹å¼ã å¦æfix_pathinfo设置æå¼,initå½æ°å°å®ç¨æ¥å³å®çå®çè·¯å¾
ããå 为é ç½®æ件ä¼æ¹å nginxçåé$fastcgi_script_name
ããfastcgi_param SCRIPT_NAME /home/gavin/nginx/$fastcgi_script_name;
ããfastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
ããå
ããfastcgi_param SCRIPT_FILENAME /home/gavin/nginx/$fastcgi_script_name;
ããfastcgi_param SCRIPT_NAME $fastcgi_script_name;
ããè¿ä¸¤ç§é ç½®é½æ¯å¯ä»¥ç
ããç¨
ããfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
ããä¹æ¯å¯ä»¥çï¼ä½å¿ é¡»ä¿è¯ $document_root 被æ£ç¡®è®¾ç½®è¿
ããâSCRIPT_FILENAMEâ
ããå½åæ§è¡èæ¬çç»å¯¹è·¯å¾å(pathname)
ããâSCRIPT_NAMEâ
ããå«æå½åèæ¬çè·¯å¾ãå½é¡µé¢éè¦æåä»ä»¬èªå·±æ¶ï¼æç¨. __FILE__ 常éå å«è·¯å¾åæ件å
ãã; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHPâs
ãã; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
ãã; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
ãã; this to 1 will cause PHP CGI to fix itâs paths to conform to the spec. A setting
ãã; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
ãã; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
ãã; cgi.fix_pathinfo=0
ãã主è¦è·CGIæ åç
ããPATH_INFO
ããPATH_TRANSLATED
ããSCRIPT_NAME
ããæå ³ç³»
ãã修修æ¹äºå¥½å¤
ããæç解å³æ¹æ³ï¼
ããæ NGINX DEFAULT é£ä¸ªæ件ä¸ç
ããfastcgi_param SCRIPT_NAME $fastcgi_script_name;
ããæ¹æå®é çè·¯å¾
ããæçæ¯fastcgi_param SCRIPT_NAME /var/www/nginx-default/$fastcgi_script_name;
ããç¶å就好äº
ãã以ä¸æ¯è½¬è½½ï¼ä¸é¢æ¯ä¸ªäººç解å³åæ³ï¼
ãã1. æ´æ¹php.ini
ããé¦å php.iniçé ç½®ä¸æ
ãã;cgi.fix_pathinfo=0 æ¹ä¸º
ããcgi.fix_pathinfo=1
ããéå¯PHPæPHP-FPM
ãã2. å¨nginx/conf/nginx.conf æ¾å°ï¼
ããfastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; æ¹ä¸ºï¼
ããfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
ããç¶åéå¯nginxãkillall -9 nginx ï¼./sbin/nginxã
ãã3ãå¦æè¿ä¸è¡ï¼è¿æä¸ç§å¯è½æ¯phpçæµè¯é¡µé¢ä»£ç æ ¼å¼æé®é¢ï¼æå½ååçæ¶åï¼phpinfoåæäºï¼<? php phpinfo(); ?> æ以éäºï¼åºè¯¥æ¯<?phpphpinfo(); ?>
ããæå¼ä¸ä¸ªé¡µé¢<?php phpinfo(); ?> ç¶åå¨æ¸¸è§å¨ä¸è¿è¡ï¼é¡µé¢æ示
ããNo input file specified.
ããFastCGI模å¼ä¸è®¿é®phpæ件æ¶ï¼åºç°No input file specified.é误
ããæ¥çaccess.log åç°æ¯ 404
ããåå åæï¼
ãã1ãä»»ä½å¯¹.phpæ件ç请æ±ï¼é½ç®åå°äº¤ç»php-cgiå»å¤çï¼ä½æ²¡æéªè¯è¯¥phpæ件æ¯å¦åå¨ãPHPæ件ä¸åå¨ï¼æ²¡åæ³è¿åæ®éç404é误ï¼å®è¿å ä¸ä¸ª404,并带ä¸ä¸å¥âNo input file specifiedâ
ãã2ãè¿å¯è½è· è·¯å¾æè æéæå ³ç³»ï¼æè SCRIPT_FILENAME åé没æ被æ£ç¡®ç设置(è¿å¨nginxæ¯æ常è§çåå )
ãã1)å¦æhtmlä¹åºç°404é误ï¼é£ä¹å°±æ¯document root 设置çæé®é¢
ãã2)æ£æ¥èæ¬æ件çæé, å¯è½PHPæè web serverä¸è½è¯»åå®
ãã3)SCRIPT_FILENAME设置é误
ããç½ä¸ç解å³æ¹æ³ï¼
ããæ¥éª¤ä¸ï¼ä¿®æ¹nginx主é ç½®æ件nginx.conf
ããé»è®¤å®è£ çnginxé ç½®æ件ä¸å®ä¹fastcgiå¤æ¯ï¼fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
ããå¯ä»¥å°å®æ¹æï¼
ããfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
ããå¿ é¡»ä¿è¯ $document_root å¨é ç½®æ件ä¸ï¼å¨astcgi_param SCRIPT_FILENAMEåé¢è¢«ç¨å°è¿ä¸æ¬¡, åé¢æ解é为ä»ä¹ã
ããæ¥éª¤äºï¼ä¿®æ¹PHPçä½é ç½®æ件php.ini
ããä¿®æ¹/etc/php5/cgi/php.iniä¸cgi.fix_pathinfo=1
ããè¿æ ·ä¹å¯è®©php-cgiæ£å¸¸ä½¿ç¨SCRIPT_FILENAMEè¿ä¸ªåé
ããæ人说ï¼è¿æ ·æ¹ä¹è¡
ããfastcgi_param SCRIPT_NAME /home/gavin/nginx/$fastcgi_script_name;
ãã让æ们ççPHP对è¿ä¸¤ä¸ªåéæ¯æä¹è§£éçå§
ããSCRIPT_NAME
ããSCRIPT_FILENAME
ããæ®è¯´,å¿ é¡»æå®æ£ç¡®çSCRIPT_FILENAME, PHP-CGIä¼å¿½ç¥SCRIPT_NAME(å³ä½¿å®çå¼è®¾ç½®çæ¯æ£ç¡®ç)
ããæè æå®ç¹æ®çphp.ini, 设置doc_root, discard path, fix pathinfoçç
ããscript_filename åªæ¯è¢«ç¨åä¸ç§å¿«æ·æ¹å¼ã å¦æfix_pathinfo设置æå¼,initå½æ°å°å®ç¨æ¥å³å®çå®çè·¯å¾
ããå 为é ç½®æ件ä¼æ¹å nginxçåé$fastcgi_script_name
ããfastcgi_param SCRIPT_NAME /home/gavin/nginx/$fastcgi_script_name;
ããfastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
ããå
ããfastcgi_param SCRIPT_FILENAME /home/gavin/nginx/$fastcgi_script_name;
ããfastcgi_param SCRIPT_NAME $fastcgi_script_name;
ããè¿ä¸¤ç§é ç½®é½æ¯å¯ä»¥ç
ããç¨
ããfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
ããä¹æ¯å¯ä»¥çï¼ä½å¿ é¡»ä¿è¯ $document_root 被æ£ç¡®è®¾ç½®è¿
ããâSCRIPT_FILENAMEâ
ããå½åæ§è¡èæ¬çç»å¯¹è·¯å¾å(pathname)
ããâSCRIPT_NAMEâ
ããå«æå½åèæ¬çè·¯å¾ãå½é¡µé¢éè¦æåä»ä»¬èªå·±æ¶ï¼æç¨. __FILE__ 常éå å«è·¯å¾åæ件å
ãã; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHPâs
ãã; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
ãã; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
ãã; this to 1 will cause PHP CGI to fix itâs paths to conform to the spec. A setting
ãã; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
ãã; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
ãã; cgi.fix_pathinfo=0
ãã主è¦è·CGIæ åç
ããPATH_INFO
ããPATH_TRANSLATED
ããSCRIPT_NAME
ããæå ³ç³»
ãã修修æ¹äºå¥½å¤
ããæç解å³æ¹æ³ï¼
ããæ NGINX DEFAULT é£ä¸ªæ件ä¸ç
ããfastcgi_param SCRIPT_NAME $fastcgi_script_name;
ããæ¹æå®é çè·¯å¾
ããæçæ¯fastcgi_param SCRIPT_NAME /var/www/nginx-default/$fastcgi_script_name;
ããç¶å就好äº
ãã以ä¸æ¯è½¬è½½ï¼ä¸é¢æ¯ä¸ªäººç解å³åæ³ï¼
ãã1. æ´æ¹php.ini
ããé¦å php.iniçé ç½®ä¸æ
ãã;cgi.fix_pathinfo=0 æ¹ä¸º
ããcgi.fix_pathinfo=1
ããéå¯PHPæPHP-FPM
ãã2. å¨nginx/conf/nginx.conf æ¾å°ï¼
ããfastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; æ¹ä¸ºï¼
ããfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
ããç¶åéå¯nginxãkillall -9 nginx ï¼./sbin/nginxã
ãã3ãå¦æè¿ä¸è¡ï¼è¿æä¸ç§å¯è½æ¯phpçæµè¯é¡µé¢ä»£ç æ ¼å¼æé®é¢ï¼æå½ååçæ¶åï¼phpinfoåæäºï¼<? php phpinfo(); ?> æ以éäºï¼åºè¯¥æ¯<?phpphpinfo(); ?>
温馨提示:答案为网友推荐,仅供参考