静的WordPress向けNginxのfastcgi_cache設定

WordPressで開発した静的ウェブサイトを公開するためにnginxの設定を見直したときの覚書。環境: CentOS 6.7, nginx 1.8.0, PHP 5.6.15fastcgi_cacheはPHP-FPMなどのバックエンドの結果をキャッシュする機能。Nginxの設定ファイルの記述はWordPressの公式サイトを参考にした。Nginx | WordPress Codex設定ファイルをGistにアップしたのでこっちを見ながらの方が分かりやすいかも。Nginx Configuration Files for WordPress | Gist目次FastCGIキャッシュ機能を有効に Nginxの設定ファイルを準備(キャッシュなし) キャッシュ機能が有効な設定ファイル Gzipの設定ファイル1.FastCGIキャッシュ機能を有効にNginx全体の設定なのでhttpディレクティブに記述する必要がある。
# cd /etc/nginx/
# less nginx.confhttp {
# FastCGI Cache
fastcgi_cache_path /var/cache/nginx/fastcgi levels=1:2 keys_zone=WORDPRESS:100m inactive=1d;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
}
ゾーン名: WORDPRESS
共有メモリ使用サイズ: 100M
保持期間: 1日間2.Nginxの設定ファイルを準備(キャッシュなし)各サイトごとの設定
# cd conf.d/共通の設定ファイルを作って、各サイトでincludeさせる。まずはアクセス制限用設定ファイルを作成
# mkdir global
# vi global/wordpress_restrictions.conf#
# Global Restrictions for WordPress site
# Designed to be included in any server {} block.</p>
#loc…
# cd /etc/nginx/
# less nginx.confhttp {
# FastCGI Cache
fastcgi_cache_path /var/cache/nginx/fastcgi levels=1:2 keys_zone=WORDPRESS:100m inactive=1d;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
}
ゾーン名: WORDPRESS
共有メモリ使用サイズ: 100M
保持期間: 1日間2.Nginxの設定ファイルを準備(キャッシュなし)各サイトごとの設定
# cd conf.d/共通の設定ファイルを作って、各サイトでincludeさせる。まずはアクセス制限用設定ファイルを作成
# mkdir global
# vi global/wordpress_restrictions.conf#
# Global Restrictions for WordPress site
# Designed to be included in any server {} block.</p>
#loc…