Saturday, June 11, 2016

Install PHP Redis in XAMPP on Ubuntu 16.04 LTS

Probably, you are here because you are trying to install phpredis in XAMPP on Ubuntu 16.04 LTS. You might already tried the steps described in this git repo. The problem is soon you will realize that the php5-dev is not available for Ubuntu 16.04 LTS. Here I will try to explain all the steps to setup XAMPP with phpredis on Ubuntu 16.04 LTS.

Install XAMPP

If you already have the XAMPP installed then skip to the next section. Otherwise, by following the steps below you can install XAMPP v5.6.21.
  • Open your terminal
  • Run the following command. This will download the installer.
wget https://www.apachefriends.org/xampp-files/5.6.21/xampp-linux-x64-5.6.21-0-installer.run
  •  Make the installer executable
chmod +x xampp-linux-x64-5.6.21-0-installer.run
  • Run the installer
./xampp-linux-x64-5.6.21-0-installer.run
  • Following the instruction will install the XAMPP on default location /opt/lampp. During this installation process please select both "xampp core files" and "xampp developer files" to install both of them.

Install Redis Server

If you already have the Redis Server installed then skip to the next section. Otherwise, installed it by typing the following command in your terminal.
sudo apt-get install redis-server

Install "phpredis"

  • Install git
sudo apt-get install git
  • Run the following commands to get the source code from git
git clone git://github.com/nicolasff/phpredis.git && cd phpredis
  • Install autoconf
sudo apt-get install autoconf 
  •  Do phpize. By default the phpize should be in /opt/lampp/bin/phpize if you install XAMPP in /opt/lampp. If this is the case then type the following command in your terminal.
/opt/lampp/bin/phpize
  • Configure. Again, if /opt/lampp is not your installation directory then replace /opt/lampp with your installation path in the following command.
./configure --with-php-config=/opt/lampp/bin/php-config & make & sudo -s make install
  • Write the following line at the end of /opt/lampp/etc/php.ini file.
extension="redis.so"
  •  Restart the XAMPP
sudo /opt/lampp/lampp restart
Now you can see through your phpinfo page that redis extension is enabled! If you are looking for a similar guide for CentOS then checkout Php redis module installation for CentOs 6.6