nginx不解析php请求

nginx不解析php请求

本文介绍了nginx不解析php请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

env:Ubuntu 9.10/使用gotdeb源码/PHP版本5.3.1/php5-fpm已安装/

env:ubuntu 9.10 /use gotdeb source /php version 5.3.1 /php5-fpm installed /

php5-fpm正在运行,并通过下面的2条命令监听9000端口测试

php5-fpm is running , and listening 9000 port test by 2 commands below

pgrep php5-fpm
telnet localhost 9000

但是,如果我使用此地址从局域网中的另一台计算机上访问

however if I visit from anthor computer in LAN ,using this address

http://192.168.1.103/index.php

浏览器要求我保存此index.php,但是如果访问index.php,一切都会很好

the browser ask me to save this index.php , but if visit index.php , everything goes well

启用站点/默认文件内容环境:Ubuntu 9.10/使用gotdeb源码/PHP版本5.3.1/php5-fpm已安装/

sites-enabled/default file contentenv:ubuntu 9.10 /use gotdeb source /php version 5.3.1 /php5-fpm installed /

php5-fpm正在运行,并通过下面的2条命令监听9000端口测试

php5-fpm is running , and listening 9000 port test by 2 commands below

pgrep php5-fpm
telnet localhost 9000

但是,如果我使用此地址从局域网中的另一台计算机访问

however if I visit from anthor computer in LAN ,using this address

http://192.168.1.103/index.php

浏览器要求我保存此index.php,但是如果访问index.html,一切都会很好

the browser ask me to save this index.php , but if visit index.html , everything goes well

启用网站/默认文件内容

sites-enabled/default file content

location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000
    fastcgi_index index.php
    fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name
    include fastcgi_params
}

推荐答案

一个常见的陷阱是,当您的代码使用短打开标记<?而不是<?php时,并且在全新安装中未在php.ini中启用它,因此它不会被解析.

A common pitfall is when your code is using short open tags <? instead of <?php and it's not enabled in php.ini on a fresh install so it won't get parsed.

要启用它,请设置short_open_tag=On

这篇关于nginx不解析php请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:47