CentOS 6.6 nginx PHP 配置

/*************************************************************************
 *                    CentOS 6.6 nginx PHP 配置 
 * 说明:
 *     在VPS上安装nginx PHP配置,以供有些时候无聊使用。
 * 
 *                                     2016-11-26 深圳 南山平山村 曾剑锋
 ************************************************************************/

一、参考文档:
    1. CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
        http://blog.csdn.net/lane_l/article/details/20235909
    2. PHP-FPM does not automatically start after reboot
        http://serverfault.com/questions/459728/php-fpm-does-not-automatically-start-after-reboot
    3. OpenBSD.Nginx.MySQL.PHP环境搭建手册
        http://www.360doc.com/content/10/1211/11/4330887_77027995.shtml

二、安装:
    yum install php 
    yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm

三、测试php-cgi:
    php-cgi -b 127.0.0.1:9000

四、后台运行php-cgi:
    1. /etc/rc.d/init.d/php-fpm start
    2. chkconfig php-fpm on

五、nginx配置:
    [root@localhost /]# cat /etc/nginx/conf.d/php.conf 
    server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;
        #access_log  /var/log/nginx/log/host.access.log  main;

        location / {
            root   /home/zengjf/www;
            index  index.php index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ .php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ .php$ {
            root   /home/zengjf/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /.ht {
        #    deny  all;
        #}
    }
    [root@localhost /]# 
原文地址:https://www.cnblogs.com/zengjfgit/p/6103932.html