Installing PHP-7 with Memcached

Source: Internet
Author: User
Tags fpm php memcached

Transferred from: https://serversforhackers.com/c/installing-php-7-with-memcached

Let's install PHP7 and Nginx on a new Ubuntu 14.04 server, and manually build the "not yet packaged" memcached module for Php7.> Update:it looks like php-memcached the package were built into ppa:ondrej/php-php7.0 for PHP7, so the manual build steps are probably not Necessary any longer! Install it via the package php-memcached .

Update2:the Repository is ppa:ondrej/php-php7.0 being depreciated in favor of ppa:ondrej/php . I haven ' t had time to re-record the video, but I'll adjust the text of the article here.

First, we ll get the PHP-7 repository:

sudo apt-get updatesudo add-apt-repository ppa:ondrej/phpsudo apt-get update

Then we can install some tools and PHP7:

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    # php7.0-mcrypt is available, but is already compiled in via ppa:ondrej/php# Since php-memcached is now available, install that too:sudo apt-get install -y php-memcached

Then PHP7 is installed!

Nginx

If we want to use it with nginx, we just need to get the Nginx config up to date to use the PHP7.0-FPM ' s Unix Socke T file path. (It's different from Nginx ' s default path).

server {ListenDefault_server;root/usr/share/nginx/html;index index.html index.htm index.php; server_name localhost; location/{try_files  $uri Span class= "hljs-variable" > $uri//index.php $is _args $args ; } location ~ \.php$ {fastcgi_ Split_path_info ^ (. +\.php) (/.+) $; # note:you should has "cgi.fix_pathinfo = 0;" In php.ini # with php7.0-fpm: fastcgi_pass Unix:/run/php/php7.0-fpm.sock; fastcgi_index index.php; include fastcgi_params;}          
Memcached

The package should now being php-memcached available for the latest Memcached library, so the following manual build steps was not NEC Essary-but I ' ll leave it there just in case you ' re curious! Install it via after sudo apt-get install -y php-memcached adding the PHP7 repository.

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

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

First, we install some basics, including development packages for PHP and Memcached:

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

Then we can get the php-memcached repository, check out php7 the branch, and build it!

cd ~git clone https://github.com/php-memcached-dev/php-memcached.gitcd php-memcachedgit checkout php7phpize./configure --disable-memcached-saslmakesudo make install

The memcached.so file gets installed into /usr/lib/php/20151012/ .

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=20extension=memcached.so

Then enable it by including symlinks to this 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.inisudo 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 changessudo service php7.0-fpm restart

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

Installing PHP-7 with Memcached

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.