LoginSignup
22
26

More than 5 years have passed since last update.

Wordpressの表示をRedisでキャッシュし、高速化する(Amazon Linux)

Last updated at Posted at 2016-01-30

動作確認環境

AWSのEC2(Amazon Linux)で確認しました。

元サイトのLightning Fast WordPress with Nginx + RedisではNginx+php-fpm+redis と書いてありますが、Apacheでもちゃんと動いています。

Redis Install

amazon linux redis install
に記事を書いてあります。

PHPファイルダウンロード

RedisのPHPクライアントライブラリ(a flexible php client library for redis.)
predis.php

Wordpress、Redis連携PHPファイル
wp-index-redis.zip

ここではwgetで取得しています。

### Wordpressのルートフォルダへ移動
 cd /var/www/wordpress  

### 高速化ファイルをWordpressのルートフォルダに取得
 wget http://uploads.staticjw.com/ji/jim/predis.php
 wget http://www.jeedo.net/downloads/wp-index-redis.zip

PHPファイルインストール

上記、操作の続きです。

### 解凍
 unzip wp-index-redis.zip

### 権限設定を調整
 sudo chown apache.apache wp-index-redis.php 
 sudo chown apache.apache predis.php 
 sudo chmod 644 wp-index-redis.php 
 sudo chmod 644 predis.php 

### Wordpressの index.phpを to_index.phpにリネーム
 sudo mv index.php to_index.php

### Wordpress Redis連携高速化PHPを wp-index-redis.phpを index.phpにリネーム
 sudo mv wp-index-redis.php index.php

Apache or Nginx再起動

Webサーバを再起動します。
PHPファイルの置き換えなので、即反映されるはずですが、一応再起動しておきました。

$ sudo service nginx restart

or

$ sudo service httpd restart

参考URL

Wordpress の表示速度を驚くほど高速化させる方法!〜Redis連携

Lightning Fast WordPress with Nginx + Redis

対訳 注意事項

  1. Pages are not cached when you are logged in.
    ログイン中はキャッシュされません。

  2. Cached pages do not expire not unless explicitly deleted or reset (deleting the entire domain cache).
    ページキャッシュは明示的に消すかリセットかけるまで残りつづけます

  3. Appending a ?c=y (e.g. domain.com/?c=y) to a url deletes the entire cache of the domain. Only works when you are logged in.
    URlに?c=yを追加すると(例. http://www.example.com/?c=y )、そのドメインに対する全キャッシュをクリアします。ただし、ログインしている時に限りこの機能は有効。

  4. Appending a ?r=y to a url deletes the cache of that url.
    ?r=y としたら、そのページのキャッシュをクリアします。(例. http://www.example.com/?p=130?r=y )

  5. Refreshing (F5) a page deletes the cache of that page.
    F5キーでリフレッシュをかけたらキャッシュを消します。

  6. Script still works even if allow_fopen is disabled in php.
    PHPの設定で allow_fopenが disabled でも、Scriptはちゃんと機能します。

  7. Submitting a comment deletes the cache of that page.
    コメントが投稿された際にはキャッシュはクリアされます。

  8. Includes a debug mode, stats are displayed at the bottom most part after . Won’t be deleted by CloudFlare.
    デバッグモードの時、最下部に状態が表示されます。CloudFlareでは削除されません。

※英語はそれほど上手でないので、正しく翻訳できているかはわかりません。

22
26
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
26