nginx - tengine+php-fpm,訪問index.php正常,訪問index.PHP卻會吧php檔案下載過來。

來源:互聯網
上載者:User
server {    listen 80;    server_name  localhost;    access_log /data/sites_logs/default.log combined;    root /data/sites/default;    index index.htm index.html index.php;    if ( $query_string ~* ".*[\;'\<\>].*" ){        return 404;    }    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {        expires 30d;    }    location ~ .*\.(js|css)?$ {        expires 7d;    }    ###########################################隱藏index.php    location / {          index  index.htm index.html index.php;           if (!-e $request_filename) {             rewrite  ^/(.*)$  /index.php/$1  last;             break;          }      }      ##########################################pathinfo 模式#           location ~ .*\.(php|php5)?$ {#               #fastcgi_pass remote_php_ip:9000;#               fastcgi_pass unix:/dev/shm/php-cgi.sock;#               fastcgi_index index.php;#               include fastcgi.conf;#           }    location ~ \.php$ {        fastcgi_pass   phpfpm:9000;        fastcgi_index  index.php;        include        fastcgi_params;        #設定PATH_INFO並改寫SCRIPT_FILENAME,SCRIPT_NAME伺服器環境變數          set $fastcgi_script_name2 $fastcgi_script_name;          if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {              set $fastcgi_script_name2 $1;              set $path_info $2;          }          fastcgi_param   PATH_INFO $path_info;          fastcgi_param   SCRIPT_FILENAME   $document_root$fastcgi_script_name2;          fastcgi_param   SCRIPT_NAME   $fastcgi_script_name2;      }}

回複內容:

server {    listen 80;    server_name  localhost;    access_log /data/sites_logs/default.log combined;    root /data/sites/default;    index index.htm index.html index.php;    if ( $query_string ~* ".*[\;'\<\>].*" ){        return 404;    }    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {        expires 30d;    }    location ~ .*\.(js|css)?$ {        expires 7d;    }    ###########################################隱藏index.php    location / {          index  index.htm index.html index.php;           if (!-e $request_filename) {             rewrite  ^/(.*)$  /index.php/$1  last;             break;          }      }      ##########################################pathinfo 模式#           location ~ .*\.(php|php5)?$ {#               #fastcgi_pass remote_php_ip:9000;#               fastcgi_pass unix:/dev/shm/php-cgi.sock;#               fastcgi_index index.php;#               include fastcgi.conf;#           }    location ~ \.php$ {        fastcgi_pass   phpfpm:9000;        fastcgi_index  index.php;        include        fastcgi_params;        #設定PATH_INFO並改寫SCRIPT_FILENAME,SCRIPT_NAME伺服器環境變數          set $fastcgi_script_name2 $fastcgi_script_name;          if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {              set $fastcgi_script_name2 $1;              set $path_info $2;          }          fastcgi_param   PATH_INFO $path_info;          fastcgi_param   SCRIPT_FILENAME   $document_root$fastcgi_script_name2;          fastcgi_param   SCRIPT_NAME   $fastcgi_script_name2;      }}

你php-fpm配置的不符吧 本地應該是 127.0.0.1:9000 你phpfpm:9000 phpfpm是網域名稱還是什麼 看看nginx的日誌 說什麼

被mac os分區格式坑了一把。
mac os分區格式有2種:
1、Mac OS 擴充(區分大小寫,日誌式)
2、Mac OS 擴充(日誌式)
我的主盤分區預設是第二種。通過docker掛在的話,就出現了這樣的問題。
如果是伺服器環境應該不會有這樣的問題。

location ~* \.php$
~* 表示不區分大小寫.

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.