是在qeephp论坛看到的一条规则,排除所有带 “.”的请求,其余的全部重写向index.php

[ISAPI_Rewrite]
RewriteCond Host: www.xxx.com
RewriteRule ^([^.]+)$ /index.php/$1 [L]

由于sitemap模块动态生成 sitemap.xml,所以也需要重写向index.php

RewriteCond Host: www.xxx.com
RewriteRule /sitemap.xml /index.php/sitemap [L]

测试环境

YardVPS $3.5套餐 (之前的介绍)

Debian 5 + Nginx0.7.67 + php5.3.3 + php5-fpm + mysql5.0.51

测试站:购乐宝

缓存方式:apc

测试方式 webbench 10并发 30秒

 

$webbench -t 30 -c 10 http://www.golebo.com/

不使用用户缓存 最好结果

Benchmarking: GET http://www.golebo.com/
10 clients, running 30 sec.
Speed=866 pages/min, 408085 bytes/sec.
Requests: 433 susceed, 0 failed.

 

使用用户缓存,最好结果

Benchmarking: GET http://www.golebo.com/
10 clients, running 30 sec.
Speed=8260 pages/min, 3907868 bytes/sec.
Requests: 4130 susceed, 0 failed.

 

10倍的速度提升,相信启用缓存非常有效!

 

今天装完joomla,能进后台,但是前台一直报502 Bad Gateway错误,网上搜索后找到解决办法,是由于Nginx中FastCGI buffer不够,这是张宴前辈的配置
修改nginx.conf,添加如下fastcgi设置
http {

  ********

    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;
  *******
}

kohana官方手册中的规则有点小问题,这是我测试通过的规则

红色的地方是特别注意的地方,要求nginx版本> 0.7.31

debian 5 现在的Nginx才在0.6.x  之前试了很久都出错

现在使用

Dotdeb的 php5.3 php5-fpm php5-cgi

debian 6 中的 nginx 0.7.67

server {
    server_name  golebo.com;
    root   /home/xxxx/www/golebo.com;

    location / {
        index  index.html index.htm index.php default.php;
        try_files $uri $uri/ /index.php$uri?$args;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
    location ~ ^(.+.php)(.*)$ {
        fastcgi_split_path_info ^(.+.php)(.*)$;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO          $fastcgi_path_info;
        include        fastcgi_params;
    }
}

location / {
        index  index.html index.htm index.php;

        if (-f $request_filename/index.html){
            rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename/index.php){
            rewrite (.*) $1/index.php;
        }
        if (!-f $request_filename){
            rewrite (.*) /index.php;
        }

    }

安装mysql

apt-get install mysql-server

安装php

apt-get install php5-common php5-cgi php5-mysql php5-curl php5-gd php5-imagick php5-mcrypt  php5-sqlite php-apc

安装Nginx

apt-get install nginx

安装spawn-fcgi

$wget http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.gz
$tar -xvf spawn-fcgi-1.6.3.tar.gz
$cd spawn-fcgi-1.6.3
$./configure –prefix=/usr
$make

$sudo make install

启动php5-cgi
$spawn-fcgi -a 127.0.0.1 -p 9000  -u www-data -g www-data -f /usr/bin/php5-cgi

配置Nginx

修改/etc/nginx/sites-available/default
# 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  /var/www/nginx-default$fastcgi_script_name;
include        fastcgi_params;
}

重启nginx
/etc/init.d/nginx restart