Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
litespeed_wiki:cache:redis [2017/08/23 20:04] Eric Leu [Install Redis PHP extension] |
litespeed_wiki:cache:redis [2020/03/03 14:22] Jackson Zhang [Install Redis PHP extension] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== How to setup Redis with LSWS for WordPress ===== | + | ====== How to integrate Redis with WordPress on LSWS ===== |
- | Redis is an open source, in-memory data structure store, used as a database, cache and message broker. [[https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache | LSCache]] is the world's fastest full page caching. So it's a good way for you to have both of them setup on your server. | + | Redis is an open source, in-memory data structure store, used as a database, cache and message broker. [[litespeed_wiki:cache | LSCache]] is the world's fastest full page caching. So it's useful for you to have both of them setup on your server. This guide can be used both with and without a control panel. |
- | This guide is valid for both with/without control panels. | + | |
==== Install Redis daemon ==== | ==== Install Redis daemon ==== | ||
- | For both cPanel and Native setup on CentOS 7: | + | For cPanel/Plesk/DirectAdmin and Native LSWS setup on CentOS 7: |
- Add the EPEL repository: \\ <code>yum install epel-release </code> | - Add the EPEL repository: \\ <code>yum install epel-release </code> | ||
- Install Redis: \\ <code>yum install redis</code> | - Install Redis: \\ <code>yum install redis</code> | ||
Line 13: | Line 12: | ||
=== With cPanel EasyApache 4=== | === With cPanel EasyApache 4=== | ||
- | Copy and paste the entire block into SSH | + | - Installing the Redis PHP extension for all available versions of PHP (Copy and paste the entire block of text together - don't copy/paste line-by-line): <code>for phpver in $(ls -1 /opt/cpanel/ |grep ea-php | sed 's/ea-php//g') ; do |
- | - Installing the Redis PHP extension for all available versions of PHP: \\ <code>for phpver in $(ls -1 /opt/cpanel/ |grep ea-php | sed 's/ea-php//g') ; do | + | |
cd ~ | cd ~ | ||
wget -O redis.tgz https://pecl.php.net/get/redis | wget -O redis.tgz https://pecl.php.net/get/redis | ||
Line 39: | Line 37: | ||
Redis Support => enabled </code> | Redis Support => enabled </code> | ||
- | * Note: | + | **Note:** |
- | * Checking newest PHP redis version [[https://pecl.php.net/package/redis | here]] | + | * You can check for the newest PHP redis version [[https://pecl.php.net/package/redis | here]] |
- | * For More description please follow [[https://github.com/phpredis/phpredis/ | Git]] | + | * To learn more please follow [[https://github.com/phpredis/phpredis/ | phpredis at Git]] |
+ | === With Plesk === | ||
+ | General Plesk support php-redis extention\\ | ||
+ | {{:litespeed_wiki:cache:redis-7.png?600|}}\\ | ||
+ | If your Plesk version not support php-redis by default, please try compile [[https://talk.plesk.com/threads/redis-activation-installation-problems-plesk-onyx.342245/ | Follow Here]] | ||
+ | |||
+ | === With DirectAdmin === | ||
+ | DirecAdmin custombuild 2 will install phpxx to /usr/local/phpxx, you can go to the version you want (such as php73) to build php-redis through pecl: | ||
+ | | ||
+ | cd /usr/local/php73/bin | ||
+ | ./pecl install igbinary igbinary-devel | ||
+ | ./pecl install redis | ||
+ | | ||
+ | Check the path of extensions. | ||
+ | ll /usr/local/php73/lib/php/extensions/ | ||
+ | drwxr-xr-x 2 root root 76 Mar 3 14:05 no-debug-non-zts-20180731 | ||
+ | | ||
+ | Then add both igbinary.so and redis.so to a newly created 10-directadmin.ini | ||
+ | vi /usr/local/php73/lib/php.conf.d/10-directadmin.ini | ||
+ | | ||
+ | extension=/usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731/redis.so | ||
+ | extension=/usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731/igbinary.so | ||
+ | |||
+ | Restart lsphp to make the change effective: | ||
+ | killall -9 lsphp | ||
+ | | ||
=== Without control panel === | === Without control panel === | ||
- Add the litespeed repository: \\ <code>rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm</code> | - Add the litespeed repository: \\ <code>rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm</code> | ||
- List the litespeed Redis PHP extension \\ <code>yum list | awk '/lsphp/&&/redis/'</code> | - List the litespeed Redis PHP extension \\ <code>yum list | awk '/lsphp/&&/redis/'</code> | ||
- | - Install PHP version depends on which version you are using: \\ <code>yum -y install lsphp71-pecl-redis</code> | + | - Install PHP (substitute the your lsphp version if it is different): \\ <code>yum -y install lsphp71-pecl-redis</code> |
==== Verify the Installation ==== | ==== Verify the Installation ==== | ||
- Verify that Redis is running with redis-cli: \\ <code>redis-cli ping</code> \\ If Redis is running, it will return: <code>PONG</code> | - Verify that Redis is running with redis-cli: \\ <code>redis-cli ping</code> \\ If Redis is running, it will return: <code>PONG</code> | ||
- | - Verify by using LiteSpeed default PHP info page http://Server_IP:8088/phpinfo.php: \\ {{:litespeed_wiki:cache:redis-1.png?700|}} | + | - Verify by using LiteSpeed default PHP info page ''<nowiki>http://Server_IP:8088/phpinfo.php</nowiki>'': \\ {{:litespeed_wiki:cache:redis-1.png?700|}} |
==== Try the redis-benchmark utility==== | ==== Try the redis-benchmark utility==== | ||
Line 77: | Line 100: | ||
</code> | </code> | ||
- | * Note: | + | **Note:** For more redis benchmark information, please refer to [[https://redis.io/topics/benchmarks | this]] |
- | * For more redis benchmark information, please refer [[https://redis.io/topics/benchmarks | here]] | + | |
==== Integrate WordPress with Redis ==== | ==== Integrate WordPress with Redis ==== | ||
- | - WordPress install **Redis Object Cache** Plugin \\ {{:litespeed_wiki:cache:redis-5.png?400|}} | + | Please refer the following article |
- | - Activate and click **Enable Object Cache** button \\ {{:litespeed_wiki:cache:redis-2.png?600|}} | + | [[litespeed_wiki:cache:lscwp:configuration:cache:object_cache|Memcached, LSMCD and Redis (Object Cache) Support in LSCWP]] |
- | - Confirm Status is ''Connected'' \\ {{:litespeed_wiki:cache:redis-3.png?600|}} | + | |
- | - Confirm Diagnostics shows Redis with version \\ {{:litespeed_wiki:cache:redis-6.png?600|}} | + | |
- | - Edit ''wp-config.php'' and at the end of the ''Authentication Unique Keys and Salts'' section, add the following lines: | + | |
- | - <nowiki>define('WP_CACHE_KEY_SALT', 'string');</nowiki> | + | |
- | - <nowiki>define('WP_CACHE', true);</nowiki> | + | |
- | - Restart LSWS \\ <code>service lsws restart</code> | + | |
- | - Test WordPress is communicating with Redis by monitor command: \\ <code> redis-cli monitor </code> {{:litespeed_wiki:cache:redis-4.png?300|}} | + | |
Line 96: | Line 111: | ||
* To automatically start Redis on boot: \\ <code>systemctl enable redis</code> | * To automatically start Redis on boot: \\ <code>systemctl enable redis</code> | ||
* For disk persistence, you can set ''/etc/redis.conf'': | * For disk persistence, you can set ''/etc/redis.conf'': | ||
- | * appendonly yes | + | * ''appendonly yes'' |
- | * appendfsync everysec | + | * ''appendfsync everysec'' |
- | * More Redis Security information please follow [[https://redis.io/topics/security | here]] | + | * For more Redis Security information please refer to [[https://redis.io/topics/security | this]] |
- | + | ||