Install memcached and memcache extensions to PHP under Linux

Source: Internet
Author: User

Memcached php module

Http://kimi.it/257.html (Additional method)
Linux installation memcached and memcache extensions
First, install the Libevent function library
: http://libevent.org
Default is installed in:/usr/local/lib directory
You need to install the Libevent library before installing memcached.
Available through #ls-al/usr/local/lib | The grep libevent command checks to see if the Libevent function library is installed.
If it is not installed, download and install the Libevent function library.
Php memcached module
Second, installation memcached
: http://memcached.org
Default is installed in:/usr/local/bin directory
After the installation is complete,
Add the Libevent package path to the/etc/ld.so.conf file first
#vi/etc/ld.so.conf
Join/usr/local/lib on the last line

When finished, enter the following command to start the memcached main program
/usr/local/bin/memcached-d-M 1024-u root-l need to access memcached client IP address-p 11211-c 1024-p/tmp/memcached.pid
Common startup parameters are as follows:
-M: Maximum use of memory, in megabytes, default 64.
-P: TCP process port used by the process, default 11211.
-D: Run memcached as the daemon daemon.
-U: Starts the user.
-P: Process file storage path.
-C: Maximum number of running concurrency, default 1024.
-L: Listens for service addresses (that is, IPs that allow Telnte logons).

If the following error occurs: Error while loading shared Libraries:libevent-2.0.so.5:cannot open Shared object File:no such file or director Y
The memcached can not find the location of libevent, the solution and reasons are as follows:
One of the reasons: although we have just added the Libevent package directory to the/etc/ls.so.conf file, the system has not yet identified this new dynamic link library.
Workaround: We need to execute the ldconfig command, which usually runs at system startup, and when the user installs a new dynamic link library, it is necessary to run the command manually.
Purpose of this command: default search for/lilb and/usr/lib, and library files in the directory listed in the configuration file/etc/ld.so.conf.

After the boot is complete, you can see if the memcached main program exists
#pstree | grep mem

Third, install memcache extension
: Http://pecl.php.net/package/memcache
Memcache is an extension module for PHP, which should be guaranteed to have PHP environment before installation.
Find the Phpize directory first (if it's PHP installed via Yum, it exists in/usr/bin, if they are not found, #yum install Php-devel and restart)
After unpacking the Memcache package, "Go to the extracted folder". Next, use Phpzie to compile the memcache into the PHP extension module.
#/usr/bin/phpize
#./configure--with-php-config=/usr/bin/php-config
(At this time if Error:memcache support requires zlib error, it means that there is no zlib, you can yum one, then restart: #yum install-y zlib.x86_64 zlib-devel.x86_64)
After the test is successful, you can compile the memcache with make:
#make
#make Install
Installing Shared extensions:/usr/lib64/php/modules/
(The result above indicates that the extension will be installed into the/usr/lib64/php/modules/directory)
Finally, you need to modify the PHP.ini configuration item, as follows:
#vim/etc/php.ini
(in more than 700 lines find the following command, remove the comments, some can not be added manually)
Extension_dir = "/usr/lib64/php/modules/"
Extension = "memcache.so"
Extension = "pdo_mysql.so"
Restarting the server

can use #telnet memcached server IP address 11211
To see if you can connect memcached

Memcache configuration information can then be viewed through the Phpinfo function


Linux installs memcached and memcache extensions to PHP (RPM)


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.