0

How can I install memcached from php.net and work it with php7+? I tried a couple of tutorials from other sites (I do not remember now) but it does not work. Can anyone help me to do this, I am quite new with Ubuntu and web development, so anything may help me.

googol8080
  • 31
  • 2
  • 8

2 Answers2

1

This is solution for you complete steps to install the memcached and php7 on Ubuntu OS:

First, You get and instal the PHP-7 and memcached:

sudo apt-get update
sudo apt-get install -y tmux curl wget \
    nginx \
    php7.0-fpm \
    php7.0-cli php7.0-curl php7.0-gd \
    php7.0-intl php7.0-mysql php-memcached

Then PHP7 is installed!

Seconds, If php-memcached was not installed, we can build it manually. (However, it's likely available to install via the php7.0-memcached package now).

If you need a newer version of the PHP-Memcached module, we can build it manually. Here's how:

sudo apt-get install -y php7.0-dev git pkg-config build-essential libmemcached-dev
sudo apt-get install -y libmemcached-dev libmemcached11 git build-essential

git clone https://github.com/php-memcached-dev/php-memcached
cd php-memcached
git checkout php7
git pull

/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config

make
sudo make install

Then we need to setup PHP (CLI and FPM) to use the memcached module. Edit /etc/php/mods-available/memcached.ini, add:

; configuration for php memcached module
; priority=20
extension=memcached.so

Then enable it by including symlinks to that file in the FPM/CLI conf.d directories:

sudo ln -s /etc/php/mods-available/memcached.ini /etc/php/7.0/fpm/conf.d/20-memcached.ini
sudo ln -s /etc/php/mods-available/memcached.ini /etc/php/7.0/cli/conf.d/20-memcached.ini

Reload php-fpm to include the new changes

sudo service php7.0-fpm restart

And there we have it, PHP7 is installed, with Memcached support!

Kotler
  • 609
0

On Ubuntu 18.04, you need to get php-memcached from a nonstandard repo:

sudo apt-get install libmemcached-tools
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

Then, if you hadn't done this yet:

sudo apt-get install php php-dev php-pear libapache2-mod-php

Finally:

sudo apt-get install php-memcached
service apache2 restart