wp-cli Configuring WordPress with Redis
To enable Redis, you’ll have to have Redis installed on your site. You can request this from Servebolt support. There are multiple plugins available to enable Redis for WordPress. This example uses the plugin Redis Cache which has 60K installs and is actively maintained.
After you have received confirmation from support that Redis is enabled for your site, you can enable it by following this recipe.
- Add the configuration to wp-config.php
Add configuration using wp-cli from the command line:
1$ wp config set WP_REDIS_PATH --raw "__DIR__ . '/../redis.sock'"
2$ wp config set WP_REDIS_SCHEME "unix"
alternatively, you can do this by editing wp-config.php
and adding the following defines:
1define('WP_REDIS_PATH', __DIR__ . '/../redis.sock'); define('WP_REDIS_SCHEME', 'unix');
Please not that if you are running WordPress out of some other directory or subfolder, you’ll have make the path to the socket relative to your applications directory.
- Install the Redis Cache plugin
1$ wp plugin install redis-cache --activate
-
Enable Redis in the WordPress pluginIn your WordPress administrator panel: wp-admin –> plugins, you should see the Redis Object Cache plugin. Click the settings of that plugin and enable Redis Object Cache.
-
Verify that it is working
You can start the Redis monitor from the command line by running the following command
1$ redis-cli -s ~/redis.sock monitor
After this, click around on your site a few times. You’ll see an OK first and then massive amounts of text scrolling by. This is the data stored and pulled from the Redis cache.
If the redis server didnot have the same host with wordpress, we can alow use this command configre:
1wp config set WP_REDIS_HOST "192.168.0.100" --allow-root --path=/var/www/html/
2wp config set WP_REDIS_PORT 6379 --allow-root --path=/var/www/html/
3wp config set WP_REDIS_PASSWORD password --allow-root --path=/var/www/html/
捐赠本站(Donate)
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))
- Author: shisekong
- Link: https://blog.361way.com/wp-wordpress-redis/6988.html
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.