---
title: "Nginx 开启对 PHP 的解析（转）"
author: "as619864232"
date: "2013-06-30T00:27:57Z"
tags: []
categories: ["企业架构"]
slug: "nginx-php"
draft: false
lastmod: "2013-06-30T00:28:18Z"
id: 1896542
url: "https://ears.iteye.com/blog/1896542"
---

安装 PHP 和 nginx 后，无法解析 PHP 文件。

其中，PHP 和 nginx 的编译安装 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

 

 

转自：[http://www.oschina.net/question/231397\_36992](http://www.oschina.net/question/231397_36992)