OpenLiteSpeed with PHP7 & Memcache(d)

I recently wanted to configure and use Memcached instead of the default disk caching for my Revive AdServer which was running OpenLitespeed with PHP7 and since it wasn’t a simple one click install I’ve decided to make a tutorial about it.

I will not go into details about setting up OpenLiteSpeed and PHP7 on Debian Jessie as I’ve already covered the subject in this tutorial.

So assuming you have already setup OpenLiteSpeed with PHP7 and just need Memcached and the PECL-Memcache extension to make things work you will need to follow some basic steps to get the ball rolling:

Install Memcached using APT:

apt-get install memcached

Install the dependencies needed to compile the PECL-Memcache extension:

apt-get install git autoconf

Clone the latest version of the PECL-Memcache extension for PHP7 using Git from the Github repository:

cd /tmp; git clone https://github.com/websupport-sk/pecl-memcache.git

Build the PECL-Memcache extension:

cd pecl-memcache
/usr/local/lsws/lsphp7/bin/phpize && ./configure –enable-memcache –with-php-config=/usr/local/lsws/lsphp7/bin/php-config && make && make install

Find out where the php.ini should be:

/usr/local/lsws/lsphp7/bin/php -i | egrep ‘php.ini|/openlitespeed/php.d/’

NOTE: By default, PHP7 for OpenLiteSpeed does not deploy a php.ini so we’ll have to copy the one from PHP 5.6 which is installed by default. The command listed above should indicate that the directory for the php.ini in the PHP7 build is defined as: /usr/local/lsws/lsphp7/lib

 cp /usr/local/lsws/lsphp56/etc/php.ini /usr/local/lsws/lsphp7/lib

The last step to make it work is to define the extension by appending the following line in php.ini:

extension = memcache.so

and restart the OpenLiteSpeed server daemon:

service lsws restart

Next, to make sure that the Memcached daemon is running you can execute the following command:

service memcached status

which should print the following output:

● memcached.service – memcached daemon
Loaded: loaded (/lib/systemd/system/memcached.service; enabled)
Active: active (running) since Fri 2016-10-28 08:10:53 CEST; 16min ago
Main PID: 8386 (memcached)
CGroup: /system.slice/memcached.service
└─8386 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1

Oct 28 08:10:53 indigo systemd[1]: Started memcached daemon.

That’s pretty much about it. Pretty easy isn’t it?

Latest Comments
  1. Betro Hakala
  2. Betro Hakala

Post A Comment

Your email address will not be published. Required fields are marked *