速度を求めて、、、
RaspberryPiでWordPress立ち上げまでは来たけど何となくまだ遅い。
Nginxの高速化を試してみる。
リバースプロキスより構成が単純→処理も軽いと勝手に考えてFastCGI-chache導入
参考サイト
というかほぼ丸パクリ。多謝多謝。
Nginxのfastcgi_cacheでWordPressを高速化
設定内容(記録)
nginx.confに「Fast CGI」設定を追記
##
# Fast CGI Settings
##
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=czone:10m inactive=7d max_size=1000m;
server設定を変更
server{
listen 80;
client_max_body_size 20M;
server_name xxxxxxxx1.YYYYYYYY.0t0.jp;
access_log /var/log/nginx/xxxxxxxx1.log;
index index.php index.html index.htm;
root /var/www/html/xxxxxxxx1;
set $mobilef '';
if ($http_user_agent ~* '(iPhone|iPod|Android.*Mobile|Windows.*Phone|dream|CUPCAKE|BlackBerry|webOS|incognito|webmate)') {
set $mobilef 'mobile.';
}
fastcgi_cache_key "$mobilef$scheme://$host$request_uri";
set $do_not_cache 0;
if ($request_method !~ ^(GET)$) {
set $do_not_cache 1;
}
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $do_not_cache 1;
}
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $do_not_cache 1;
}
location / {
try_files $uri $uri?$args $uri/ /index.php?$uri&$args /index.php?$args;
}
location ~ \.php$ {
root /var/www/html/xxxxxxxx1;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_cache_bypass $do_not_cache;
fastcgi_no_cache $do_not_cache;
fastcgi_cache czone;
fastcgi_cache_valid 200 302 7d;
fastcgi_pass_header X-Accel-Expires;
}
}
WordPressプラグイン追加
「Nginx Cache Controller」を追加
functions.phpの追記(修正)
上記参考サイトのまま