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.
  •  Make the installer executable
chmod +x
  • Run the installer
  • 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:// && 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.
  • 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.
  •  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

1 comment:

  1. make is giving error

    /opt/lampp/phpredis/common.h:12:28: fatal error: zend_smart_str.h: No such file or directory