Install Magento on an Ubuntu 14.04 VPS and Enable Redis as Back End Cache

magento vpsMagento Community Edition is a flexible and robust open source content management system for e-commerce web sites. In this tutorial we will show you how to install Magento and configure Redis (an open source advanced key-value cache and store) for back end caching on an Ubuntu VPS.

Download the latest version of Magento from, extract it and move the Magento installation to the ‘/var/www/html/magento/’ directory on your VPS:

cd /root/
tar -xzvf magento-

mv /root/magento /var/www/html/magento/

Set proper permissions:

chown www-data:www-data -R /var/www/html/magento/
cd /var/www/html/magento
chmod -R o+w app/etc/
chmod -R o+w var/
chmod -R o+w media/

Create a new database for Magento:

mysql -u root -p 
mysql> create database magentodb;
mysql> GRANT ALL PRIVILEGES ON magentodb . * TO magento@'localhost' IDENTIFIED BY 'your-password' WITH GRANT OPTION;
mysql> flush privileges;
mysql> quit

Install Redis:

apt-get install redis-server

Install phpRedis extension via PECL:

apt-get install php5-dev
pecl install redis

Add ‘’ to the ‘php.ini’ configuration file. To locate the ‘php.ini’ configuration file, use the following command:

php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini

Or, create ‘redis.ini’ file in the ‘/etc/php5/mods-available/’ directory:

vi /etc/php5/mods-available/redis.ini

and add these lines:

; configuration for php Redis module

Then, run the following command:

php5enmod redis

Also, enable PHP mcrypt extension as it is required by Magento:

php5enmod mcrypt

Create a new virtual host directive in Apache. For example, create a new Apache configuration file named ‘magento.conf’:

vi /etc/apache2/sites-available/magento.conf

and add the following lines:

<VirtualHost *:80>
   DocumentRoot /var/www/html/magento/
      <Directory /var/www/html/magento/>
         Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Order allow,deny
         allow from all
   ErrorLog /var/log/apache2/
   CustomLog /var/log/apache2/ common

Restart Apache for the changes to take effect using the following command:

service apache2 restart

Open and follow the easy instructions.





To configure Magento to use Redis, edit ‘/var/www/html/magento/app/etc/modules/Cm_RedisSession.xml’ file and change:




Then, edit the ‘local.xml’ file located to the ‘/var/www/html/magento/app/etc/’ directory:

vi /var/www/html/magento/app/etc/local.xml

and add the following lines after  <session_save><![CDATA[files]]></session_save>


Next, delete cache and sessions:

rm -rf /var/www/html/magento/var/session/*
rm -rf /var/www/html/magento/var/cache/*

Or, log in to the Admin panel as an administrator, click ‘System’ > ‘Cache Management’, then click ‘Flush Magento Cache’.

That is it. Magento is installed and configured to use Redis as back end cache.

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install Magento and enable Redis as back end cache 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.


5 thoughts on “Install Magento on an Ubuntu 14.04 VPS and Enable Redis as Back End Cache”

  1. Hi peeps,

    I have installed the Redis as per given above. Then how can i check the redis cache working in my project?

    Thanks peeps!


Leave a Comment

To prove you are human please solve the following *