Ubuntu16.04 add memcached and redis extension for PHP7

Source: Internet
Author: User
After Ubuntu16.04 adds memcached for PHP7 and redis extension switches to PHP 7, the website speed is greatly improved. However, a common extension may not support PHP7.

Memcached

For example, I have used the latest Ubuntu 16.04. Although PHP 7 is built in, memcached is not available yet. Fortunately, it supports PHP 7, but it only has no source, we compile it manually.

To install memcached, you must first install the dependency LibraryLibmemcached

Find the latest libmemcached source code package and download it.

wgethttps://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gztar -zxflibmemcached-1.0.18.tar.gzcdlibmemcached-1.0.18/./configuremakemakeinstall

After installing the dependency library, we will install memcached:

After cloning memcached from github, you need to manually switch to the php7 branch. Otherwise, the error "fatal error: ext/standard/php_smart_str. h: No such file or directory" is returned.

gitclone https://github.com/php-memcached-dev/php-memcached.gitcdphp-memcached/gitcheckoutphp7phpize./configure --disable-memcached-saslmakemakeinstall

Redis

Similarly, Redis already has PHP 7. we can get the project clone from github and manually switch to the PHP 7 branch:

gitclone https://github.com/phpredis/phpredis.gitcdphpredis/gitcheckoutphp7phpize./configuremakemakeinstall

Start extension

It is not enough to install the plug-in. we also need to edit the PHP configuration file to load the extension. vi/etc/php/7.0/fpm/php. ini, add the following statement to the configuration file:

extension=memcached.soextension=redis.so

Run the following command to restart the PHP service: service php7. 0-fpm restart.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.