CentOS 6.6 nginx PHP 配置

Posted zengjf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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配置:
    [[email protected] /]# 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 Apaches document root
        # concurs with nginxs one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
    [[email protected] /]# 

 

以上是关于CentOS 6.6 nginx PHP 配置的主要内容,如果未能解决你的问题,请参考以下文章

Centos 6.6 下 nginx +php mysql + phpMyadmin 安装部署

CentOS.6.6中 PHP-5.5.38安装配置

CentOS 6.6安装配置LAMP服务器(Apache+PHP5+MySQL)

带有Nginx 1.6.2的CentOS 6.6 - 突然无法重启nginx - nginx:[emerg] open()“/ usr / share / nginx / on”失败(13:权限被拒绝

CentOS release 6.6 nginx install

centos 6.6编译安装nginx--来自阿里云帮助文档