Build Lnamp Environment (vii)-PHP7 source installation memcached and memcache expansion

Source: Internet
Author: User
Tags fpm

Previous: Build Lnamp Environment (vi)-PHP7 source installation MongoDB and MongoDB expansion one, installation memcached

1.yum Installing the Libevent Event trigger manager

Yum-y Install Libevent-devel

2. Create memcached user groups and users

Groupadd Memcacheduseradd-r-G memcached-s/sbin/nologin-m memcached

3. Download the memcached source package and put the source package into the/usr/local/src/directory
Download page: http://memcached.org/downloads
Memcached-1.4.33.tar.gz is used here.
: http://memcached.org/files/memcached-1.4.33.tar.gz
4. Enter the src/directory

cd/usr/local/src/

5. Unzip the source package

TAR-ZXF memcached-1.4.33.tar.gz

6. Enter the memcached source directory, compile and install

CD memcached-1.4.33/./configure--prefix=/usr/local/memcached  --with-libeventmake && make install

7. Modify memcached Directory Permissions

Chown-r memcached:memcached/usr/local/memcached

8. Add the memcached command to the environment variable and modify the profile file

Vim/etc/profile

9. Change to the following, save exit

path=/usr/local/mysql/bin:/usr/local/php/bin:/usr/local/redis/bin:/usr/local/mongodb/bin:/usr/local/memcached/ Bin: $PATH

10. Make the configuration in/etc/profile effective immediately

Source/etc/profile

11. Add the Memcached service script to the init.d/directory to create the memcached file

Vim/etc/init.d/memcached

12. Add the following to save the exit

View Code

Parameter explanation:
/usr/local/bin/memcached-d-u memcached-m 1024-l 127.0.0.1-p 11211-c 1024-p/var/run/memcached/memcached.pid
-D launches a daemon. Multiple daemons can be started, but ports cannot be duplicated
-U user running Memcache
The amount of memory allocated by-m, in megabytes
-L Listener Server IP address, default is native
-P Listening Port
-C Maximum number of concurrent connections running, default is 1024
-P PID File location

13. Add executable permissions for memcached

chmod +x/etc/init.d/memcached

14. Adding Memcached to System services

Chkconfig--add memcached

15. Modify the default boot level for the service

Chkconfig memcached on

16. Start memcached

Service memcached Start

Second, PHP7 installation memcache expansion

1.yum Installation Zip

Yum install-y zip Unzip

2. Download the PHP7 memcache expansion pack and place the source package in the/usr/local/src/directory
: Https://codeload.github.com/websupport-sk/pecl-memcache/zip/php7/pecl-memcache-php7.zip
3. Enter the src/directory

cd/usr/local/src/

4. Unpack the expansion pack

Unzip Pecl-memcache-php7.zip

5. Enter the Memcache expansion directory, compile and install the extension

CD pecl-memcache-php7phpize./configure--with-php-config=/usr/local/php/bin/php-configmake && make install

6. Modify the php.ini file

Vim/usr/local/php/etc/php.ini

7. Add memcache.so extension configuration, save exit

Extension=memcache.so

8. Restart Apache or PHP-FPM

Service httpd Restartservice php-fpm restart

9. Add php files to the web directory, such as/usr/local/apache/htdocs/memcache.php or/usr/local/nginx/html/memcache.php

<?php$memcache = new Memcache; $memcache->connect (' 127.0.0.1 ', 11211) or Die ("Could not Connect"); $memcache Set (' Class ', ' TOEFL ');p Rint_r ($memcache->get (' class '));

Access URLs, such as: http://192.168.8.9/memcache.php
The page is displayed correctly, the configuration is successful
Memcached Installation Complete

Build Lnamp Environment (vii)-PHP7 source installation memcached and memcache expansion

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.