本文操作环境:Windows7系统、PHP5版、DELL G3电脑
访问index.php不解析怎么办?
nginx服务器访问时没解析PHP,直接下载php文件
在配置服务器的时候,有时候会出现这种情况,将域名映射到目录下,访问该域名却直接下载index.php文件。这种情况该如何解决呢?
location ~ \.php$ {
try_files $uri =404; #增加
fastcgi_split_path_info ^(.+.php)(/.+)$; #反注释
## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
## With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
## With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock; #反注释
fastcgi_index index.php; #反注释
include fastcgi_params; #反注释
# include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
}
只需在nginx服务器中配置这么一段代码,用来解析PHP。这段代码的用处是访问是php文件时自动跳转到php5-fpm去解析文件。