WordPress提速测试

我做的WordPress调整

  1. 数据库优化插件
  2. PHP+APC速度
  3. MySQL的速度
  4. WordPress的插件删除
  5. nginx+ FastCGI
  6. 超高速缓存插件
  7. nginx代理缓存

赶潮流,现在都喜欢用Nginx做前端,然后后端放Apache,小内存我不喜欢这样的组合,非常吃内存

一、先调整slow log

   

log-slow-queries = /var/log/mysql-slow.log
long_query_time = 1
log-queries-not-using-indexes

安装MYSQL优化插件,推荐两款:

WP-DBManager

http://wordpress.org/extend/plugins/wp-dbmanager/

Figment Thinking WordPress Database Table Optimizer

http://wordpress.org/extend/plugins/wordpress-database-table-optimizer/other_notes/

二、PHP+APC 速度更快

APC代码缓存,可以让你的速度更快

三、调整MYSQ的

关闭LOG:log=/var/log/mysql-query.log

我的my.cnf内容

   

skip-bdb
thread_cache_size=64
query_cache_size=128M
query_cache_limit=4MB
table_cache=128
tmp_table_size=32M
max_heap_table_size=32M
key_buffer=256M
sort_buffer=32M
myisam_sort_buffer=32M
wait_timeout=60

 

四、改Nginx+Apache为Nginx+FastCGI

参考:http://wiki.nginx.org/PHPFcgiExample

如果你使用spawn-fcgi

   

bind=/tmp/php.socket
daemon $spawnfcgi -s ${bind} -u ${server_user} -g ${server_group} -P ${pidfile} -C ${server_childs} -f ${php_cgi}

五、缓存插件

WP Super Cache

w3

六、nginx的代理缓存

Nginx+FastCGI

可参考下面的FastCGI设定

   

server {
        listen       8001;
        server_name  _;
        access_log  /var/log/nginx/fastcgi-access.log  main;
        location / {
            root  /var/www/html/htdocs;
            index  index.php index.html index.htm;
# static files
if (-f $request_filename) {
                expires 30d;
break;
}
# request to index.php
if (!-e $request_filename) {
                rewrite ^(.+)$  /index.php?q=$1 last;
}
}
        location ~ \.php$ {
            root           html;
            fastcgi_pass   unix:/tmp/php.socket;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/html/$fastcgi_script_name;
            include        fastcgi_params;
}
}

我们再看Proxy cache

   

proxy_cache_path /var/www/nginx_cache levels=1:2 keys_zone=czone:4m max_size=50m inactive=120m;
proxy_temp_path  /var/www/nginx_tmp;

然后我链接起来

   

upstream backend {
        ip_hash;
        server 127.0.0.1:8001;
}
server {
        listen 80;      
        server_name caohuan.com;
        access_log  /var/log/nginx/caohuan.com.access.log;
        error_log  /var/log/nginx/caohuan.com.error.log;
        location ~ .*\.(htm|html|jpg|JPG|gif|GIF|png|PNG|swf|SWF|css|CSS|js|JS|inc|INC|ico|ICO) {
            root    /var/www/html;
            index   index.html;
            ssi     on;
break;
}
        location /wp-admin { proxy_pass http://backend; }
        location /wp-login.php { proxy_pass http://backend; }
        location / {
if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
set $do_not_cache 1;
}
if ($http_user_agent ~* “2.0\ 2MMP|240×320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800″) {
set $do_not_cache 1;
}
            proxy_no_cache     $do_not_cache;
            proxy_cache_bypass $do_not_cache;
            proxy_pass http://backend;
            proxy_cache czone;
            proxy_cache_key $scheme$proxy_host$uri$is_args$args;
            proxy_cache_valid  200 10m;
}
}



去打赏

您的支持将鼓励我们继续创作!

[微信] 扫描二维码打赏

[支付宝] 扫描二维码打赏

正在跳转到PayPal…

点赞