In this tutorial, we are going to show you how to install and enable Redis cache in Joomla on a Linux Cloud VPS running Ubuntu 16.04 as an operating system.
Joomla is a popular and user-friendly open source CMS, written in PHP that allows web developers to create and manage dynamic websites.
This install guide assumes that a LAMP stack is installed and configured on the server. At the time of writing this tutorial, the latest stable version of Joomla is 3.6.5 and it is recommended to install it on a server with:
- PHP 5.6.x or PHP 7.x with mcrypt and Zip modules enabled;
- Apache Web Server 2.4.x with an enabled mod_rewrite module in order to use search engine friendly (SEF) or clean URLs.
- MySQL 5.5.x , or PostgreSQL 9.1.x, or SQL Server 10.50.1600.1 version or higher
Install Redis
To install and configure Redis on Ubuntu 16.04, follow these instructions.
Install Joomla
Download the latest version of Joomla available at https://downloads.joomla.org to a directory on the server and extract it using the following commands:
cd /opt wget https://downloads.joomla.org/cms/joomla3/3-6-5/joomla_3-6-5-stable-full_package-zip?format=zip -O joomla.zip unzip joomla.zip -d joomla
Move the Joomla installation to the /var/www/html/joomla directory:
mv /root/joomla/ /var/www/html/joomla
The web server user (www-data) needs to be able to write to files and directories inside the ‘/var/www/joomla’ directory, so run the following command:
chown www-data:www-data -R /var/www/html/joomla
Create a new MySQL database:
mysql -u root -p mysql> CREATE DATABASE joomladb; mysql> CREATE USER joomlauser@localhost; mysql> SET PASSWORD FOR 'joomlauser'@'localhost' = PASSWORD("your-password"); mysql> GRANT ALL PRIVILEGES ON joomladb.* TO 'joomlauser'@'localhost' IDENTIFIED BY 'your-password' WITH GRANT OPTION; mysql> FLUSH PRIVILEGES; mysql> quit
Do not forget to replace ‘your-password’ and use a strong password for the MySQL user account.
Create a new virtual host directive in Apache. For example, create a new Apache configuration file named ‘joomla.conf’:
touch /etc/apache2/sites-available/joomla.conf ln -s /etc/apache2/sites-available/joomla.conf /etc/apache2/sites-enabled/joomla.conf vi /etc/apache2/sites-available/joomla.conf
then, add the following lines:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/joomla/ ServerName yourdomain.com ServerAlias www.yourdomain.com <Directory /var/www/html/joomla/> Options FollowSymLinks AllowOverride All </Directory> ErrorLog /var/log/apache2/yourdomain.com-error_log CustomLog /var/log/apache2/yourdomain.com-access_log common </VirtualHost>
Locate the loaded PHP configuration file:
# php --ini | grep php.ini Configuration File (php.ini) Path: /etc/php/7.0/cli Loaded Configuration File: /etc/php/7.0/cli/php.ini
Edit the main PHP configuration file (‘/etc/php/7.0/cli/php.ini’) and add/modify the following settings:
magic_quotes_gpc = Off post_max_size=128M upload_max_filesize=128M display_errors = Off html_errors = Off display_startup_errors = Off log_errors = On output_buffering = Off
Install and enable mcrypt and Zip PHP modules:
apt-get update apt-get install php7.0-zip php7.0-mcrypt phpenmod mcrypt phpenmod zip
Restart the Apache web server for the changes to take effect:
service apache2 restart
Open http://yourdomain.com in your popular web browser and follow the on-screen instructions. Once finished, delete the installation directory from your server using the ‘Remove installation directory’ button, or run the following command-line command:
rm -rf /var/www/html/joomla/installation/
Enable Redis in Joomla
Log into your Joomla administration back-end at http://yourdomain.com/joomla/administrator, go to ‘System’ >> ‘Global Configuration’ >> ‘System’ >> ‘Cache Settings’ and set the following:
- Cache: On – conservative Caching
- Cache-Handler: Redis
- Platform Specific Caching: No
- Cache Time: 30 (feel free to increase the ‘Cache Time’ to 60 minutes or higher if you do not update website too often).
- Persistent Redis: Yes
- Redis Server Host: localhost
- Redis Server Port: 6379
- Redis Server Authentication: leave empty
- Redis Database: 0
Go to the top of the screen and click ‘Save & Close’.
That is it. The Joomla installation with Redis cache is now complete.
Of course, you don’t have to do any of this if you use one of our Linux Cloud VPS Hosting services, in which case you can simply ask our expert Linux admins to install Joomla and enable Redis for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
HI
Can anybody explain why the value of “Redis Database:” is “0”. Whas going happen if user put 5 or 10 or 1 ?
Redis instance supports 16 logical databases. These databases are effectively siloed off from one another, and when you run a command in one database it doesn’t affect any of the data stored in other databases in your Redis instance.
Redis databases are numbered from 0 to 15 and, by default, you connect to database 0 when you connect to your Redis instance.