nginx php-cgi php

/***************************************************************************
 *                         nginx php-cgi php
 * 說明:
 *     因爲有須要多個web訪問的需求,因而選擇使用nginx來作端口映射,剛開始配置
 * 的時候無法先php還有fpm模式,由於交叉編譯php的時候只選擇cgi,因此配置的過程
 * 中遇到問題,還有就是沒注意到要將php-cgi跑起來才行,以前經過busybox httpd是
 * 不須要這麼作的,不過目前時間久了php-cgi會掛掉。
 *
 *                                         2016-9-26 深圳 南山平山村 曾劍鋒
 **************************************************************************/

1、參考文檔:
    1. NGINX - No input file specified. - php Fast/CGI
        http://stackoverflow.com/questions/21377321/nginx-no-input-file-specified-php-fast-cgi
    2. 解決NGINX PHP "No input file specified"
        http://xiahongyuan.blog.51cto.com/906214/852424
    3. Nginx+php-cgi的配置方法介紹
        http://blog.csdn.net/bookmoth/article/details/4568203
    4. windows下配置nginx+php環境
        http://www.cnblogs.com/huayangmeng/archive/2011/06/15/2081337.html

2、修改nginx php配置:
    server {
        listen       80;
        server_name  localhost;
        root /var/www/;
        index index.html index.htm index.php;

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
            include        fastcgi_params;
        }
    } 

3、啓動php-cgi:
    1. php-cgi -b 127.0.0.1:9000 -c /etc/php.ini
    2. 開機自啓動:
        cat /etc/init.d/S51phpCGI
            echo "Start php-cgi."
            php-cgi -b 127.0.0.1:9000 -c /etc/php.ini &
相關文章
相關標籤/搜索