访问index.php不解析怎么办

访问index.php不解析怎么办,第1张

访问index.php不解析怎么办

访问index.php不解析的解决办法就是在nginx服务器中配置一段代码为“location ~ \.php$ {try_files $uri =404;fastcgi_split_path_info ^(.+.php)...}”即可。

本文 *** 作环境: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去解析文件。

推荐学习:《PHP视频教程》

以上就是访问index.php不解析怎么办的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/680807.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-20
下一篇 2022-04-20

发表评论

登录后才能评论

评论列表(0条)

保存