Enabling the Redis extension for PHP
Redis is an in‑memory data structure store often used as a cache or session handler to improve application performance. To use Redis with PHP applications (like Laravel, WordPress, or Magento) on ruachost.com, you need to enable the Redis extension.
Why Enable Redis?
Section titled “Why Enable Redis?”- Provides faster caching and session management.
- Reduces database load by storing frequently accessed data in memory.
- Improves scalability for high‑traffic websites.
- Compatible with all ruachost.com hosting accounts.
Steps to Enable Redis Extension for PHP
Section titled “Steps to Enable Redis Extension for PHP”1. Check PHP Version
Section titled “1. Check PHP Version”- Log in to cPanel at ruachost.com.
- Go to Select PHP Version under the Software section.
- Confirm your PHP version supports Redis (PHP 7.4+ recommended).
2. Enable Redis via PHP Selector
Section titled “2. Enable Redis via PHP Selector”- In Select PHP Version, look for the redis extension in the list.
- Check the box next to redis.
- Click Save to apply changes.
3. Verify Redis Installation
Section titled “3. Verify Redis Installation”-
Create a
phpinfo.phpfile in yourpublic_htmldirectory:<?php phpinfo(); ?> -
Visit
http://example.com/phpinfo.php. -
Search for redis in the output.
-
If enabled, you’ll see Redis extension details.
4. Configure Redis in Your Application
Section titled “4. Configure Redis in Your Application”-
For Laravel:
-
Update
.envfile:CACHE_DRIVER=redisSESSION_DRIVER=redisREDIS_HOST=127.0.0.1REDIS_PASSWORD=nullREDIS_PORT=6379
-
-
For WordPress:
-
Install a Redis plugin (e.g., Redis Object Cache).
-
Add to
wp-config.php:define('WP_REDIS_HOST', '127.0.0.1');define('WP_REDIS_PORT', 6379);
-
5. Test Redis Connection
Section titled “5. Test Redis Connection”-
Run a simple PHP script:
<?php$redis = new Redis();$redis->connect('127.0.0.1', 6379);echo "Connection to Redis successful!";?> -
If successful, Redis is ready for use.