Nginx-tengine + php-fpm, access index. php is normal, but access index. PHP will download the php file.

Source: Internet
Author: User
{Code ...}
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 ;} ######################################## ### hide index. php location/{index index.htm index.html index. php; if (! -E $ request_filename) {rewrite ^ /(. *) $/index. php/$1 last; break ;}} ######################################## # pathinfo mode # 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; # set PATH_INFO and rewrite SCRIPT_FILENAME, SCRIPT_NAME server environment variable set $ attributes $ fastcgi_script_name; if ($ response ~ "^ (. + \. Php )(/. +) $ ") {set $ region $1; set $ path_info $2;} fastcgi_param PATH_INFO $ path_info; fastcgi_param SCRIPT_FILENAME $ document_root $ region; fastcgi_param SCRIPT_NAME $ region ;}}

Reply content:
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 ;} ######################################## ### hide index. php location/{index index.htm index.html index. php; if (! -E $ request_filename) {rewrite ^ /(. *) $/index. php/$1 last; break ;}} ######################################## # pathinfo mode # 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; # set PATH_INFO and rewrite SCRIPT_FILENAME, SCRIPT_NAME server environment variable set $ attributes $ fastcgi_script_name; if ($ response ~ "^ (. + \. Php )(/. +) $ ") {set $ region $1; set $ path_info $2;} fastcgi_param PATH_INFO $ path_info; fastcgi_param SCRIPT_FILENAME $ document_root $ region; fastcgi_param SCRIPT_NAME $ region ;}}

Your php-fpm configuration does not match. The local configuration should be 127.0.0.1: 9000. Your phpfpm: 9000 phpfpm is a domain name or what does it mean to look at the nginx log?

The format of the mac OS partition fails.
There are two mac OS partition formats:
1. Mac OS extension (case sensitive, log-type)
2. Mac OS extension (Log Type)
My primary disk partition is the second type by default. This problem occurs when docker is used.
This problem should not occur in the server environment.

Location ~ * \. Php $
~ * Indicates case insensitive.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.