nginx+php 的配制

来源:互联网 发布:光翼第六期网络班 编辑:程序博客网 时间:2024/05/16 10:43

server
{
    listen  127.0.0.1:80;

    listen  192.168.1.201:9001;//不用绑定HOST可以直接访问端口
    charset gb2312;
    server_name test.com;
    index index.html index.htm index.php;
    root  /home/dev/aa;
   error_page 400 403 404 500 = http://域名/  ;    //错误页的中转地址
    location ~ .*/.(php|php5)?$
    {
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }

    if (!-e $request_filename){   //伪静态

        rewrite ^(.*)/honghei(.*?)$ $1/?a=red_black last;
        rewrite ^(.*)/show_([0-9]+).html$ $1/?a=detail&infoid=$2 last;
        rewrite ^(.*)/show_([0-9]+).shtml$ $1/?a=detail&infoid=$2 last;
        rewrite ^(.*)/search_top.html$ $1/?m=Default&a=search_index last;
        rewrite ^(.*)/profile(.*)$ $1/?m=Default&a=u last;

    }
    log_format  betaflashbj100com  '$remote_addr|-|$remote_user[$time_local]|-|$request'
                                 '|-|$status|-|$body_bytes_sent|-|$http_referer|-|'
                                 '$http_user_agent|-|$http_x_forwarded_for';  //日志访问格式


}

php 利用 fast-cgi 启动 fast-cgi -b 127.0.0.1:9000 -c php.ini

主要是 fcgi.conf

 

window 下启动nginx start nginx

原创粉丝点击