技术库 > Nginx

nginx php-fpm 解析不了php文件

技术库:tec.5lulu.com

from:tec.5lulu.com

安装 PHPnginx 后,无法解析 PHP 文件。

其中,PHPnginx 的编译安装 configure 如下:

# PHP 5.3.9

./configure --prefix=/usr/local/php -- enable-fpm

# nginx 1.0.11

./configure --prefix=usr/local/nginx

# 成功安装后,创建 php-fpm.conf 配置文件,删除 nginx.conf 中“pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000”部分的注释

cd /usr/local/php/etc

mv php-fpm.conf.default php-fpm.conf

vi /usr/local/nginx/conf/nginx.conf

# 删除如下部分的注释,保存退出,

location ~ .php$ {

   root           html;

   fastcgi_pass   127.0.0.1:9000;

   fastcgi_index  index.php;

   fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;

   include        fastcgi_params;

}

# 启动 php-fpm 和 nginx

/usr/local/php/sbin/php-fpm

/usr/local/nginx/sbin/nginx

------------------------------------------------------------------------

一访问php文件就下载那个php 文件了。html文件访问正常。
/etc/nginx/ 下的目录
nginx.conf
vhost/test.conf
vhost下的test.conf 是这样配置的:
server {
    listen 80;
 
    server_name test.test.com;
    root /www/test;
    access_log /var/log/nginx/$host-access.log;
    error_log  /var/log/nginx/dev-error.log error;
 
  location = /favicon.ico {
        log_not_found off;
        access_log off;
  }
 
 
 location ~ .php {
       include fastcgi_params;
       fastcgi_pass  127.0.0.1:9000;
       fastcgi_index index.php;   
       fastcgi_param SCRIPT_FILENAME /www/putianems$fastcgi_script_name;
       fastcgi_param PATH_INFO $fastcgi_script_name;
       access_log off;
    }
 
  location / {
    index index.php;
    try_files $uri /index.php?$args;
  }
}

nginx php-fpm 解析不了php文件


标签: php nginx本文链接 http://tec.5lulu.com/detail/105dsn2i5j60r8sb4.html

我来评分 :6.1
1

转载注明:转自5lulu技术库

本站遵循:署名-非商业性使用-禁止演绎 3.0 共享协议

www.5lulu.com