CENTOS6 Yum Installation memcached

Source: Internet
Author: User
Tags install php php memcached server port

centos6 Yum installation memcachedCategory: Php2013-03-08 18:08 7355 People read comments (0) favorite reports

Directory (?) [+]

CentOS 6 12th Step omitted, direct Yum installation

1. Installing a third-party software library

wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.5.2-2.rf.src.rpm
RPM-IVH rpmforge-release-0.5.2-2.rf.src.rpm

2. Find memcached

Yum Search memcached

3. Installing memcached

Yum-y Install memcached

4. Verifying the installation

Memcached-h
Some help information should be output

5. Add Memcache to the startup list

Chkconfig--level 2345 memcached on

6. Configure Memcache

Vi/etc/sysconfig/memcached
The contents of the file are as follows
port= "11211″ Port
user= user name used by "root"
maxconn= "1024″ simultaneous maximum number of connections
cachesize= "Memory size used by 64″
Options= "" Additional parameters

7. View memcache Status

Memcached-tool [Memcache server Ip]:[memcache server Port] Stats
such as: Memcached-tool 127.0.0.1:11211 stats

===== so far, we've configured the Memcache service, and then we've configured the PHP extension to call ===== in the program.

PHP has 2 types of memcache extensions, one called Memcache (released in 2002) and the other called Memcached (released in 2008)
MemcacheD is relatively new, it relies on the limemcached library to run, but it can do almost everything based on Memcache services, such as Memcached::getresultcode, It can return the result of the last operation Memcache, while Memcache does not have this function
Memcache (no D) can run without relying on any library, the installation is relatively simple, but also can complete most of the main functions of the Memcache service.
The following sections describe the installation methods for 2 people.

8. Install php memcache extension (yum install PHP has this extension installed)

wget http://pecl.php.net/get/memcache-2.2.6.tgz

wget http://pecl.php.net/get/memcache-3.0.6.tgz


Tar vxzf memcache-2.2.6.tgz
CD memcache-2.2.6
/usr/bin/phpize (If you don't know where phpize is, you can find it with Find/-name phpize)
./configure–enable-memcache–with-php-config=/usr/bin/php-config–with-zlib-dir
Make
Make install
Note the prompt after successful installation, similar to the following:
Installing Shared extensions:/usr/lib/php/modules/
Write down this address.

Add an extension extension configuration file
To see if there is a/etc/php.d/memcache.ini this file, and if it does not exist, we build a
Vi/etc/php.d/memcache.ini
Add 1 rows
Extension=memcache.so

Finally verify that the installation is complete
Php-m|grep Memcache
It should show memcache
If a similar error occurs: PHP warning:module ' memcache ' already loaded in Unknown on line 0
It would be possible to annotate the newly added extension=/usr/lib/php/modules/memcache.so of php.ini.

9. PHP memcached Extension Installation (no experiment)

First verify that the JSON header file is configured correctly
Ls/usr/include/php/ext/json/php_json.h (This is the default path, if the installation of PHP specifies a different path, see other paths)
If the file does not exist, then we need to configure the JSON header file, if it already exists, then we do not need the following steps

Confirm the JSON version, which we can view in Phpinfo (),
wget wget http://pecl.php.net/get/json-1.2.1.tgz (confirm download of the correct version)
Tar xzvf json-1.2.1.tgz
Mkdir-r/usr/include/php/ext/json/
CP json-1.2.1/php_json.h/usr/include/php/ext/json/

Installing libmemached
wget http://launchpad.net/libmemcached/1.0/0.50a/+download/libmemcached-0.50.tar.gz (do not download version 0.51, it will not complete the compilation)

Launchpad.net/libmemcached/1.0/1.0.10/+download/libmemcached-1.0.10.tar.gz, this is the latest version.
TAR-XZVF libmemcached-0.50.tar.gz
CD libmemcached-0.50.tar.gz
./configure–prefix=/usr/local/libmemcached–with-memcached
Make
Make install

Install the memcached extension again
wget http://pecl.php.net/get/memcached-1.0.2.tgz
Tar xzvf memcached-1.0.2.tgz
CD memcached-1.0.2
./configure–enable-memcached–with-php-config=/usr/bin/php-config–with-zlib-dir–with-libmemcached-dir=/usr/ Local/libmemcached–prefix=/usr/local/phpmemcached
Make
Make install
Note the prompt after successful installation, similar to the following:
Installing Shared extensions:/usr/lib/php/modules/

Add an extension extension configuration file
Vi/etc/php.d/memcached.ini
Add 1 rows
Extension=memcached.so

Finally verify that the installation is complete
Php-m|grep memcached
It should show memcached

If you modify php.ini directly when you add an extension so file, you may receive the following error:
/usr/lib/php/modules/memcached.so:undefined Symbol:php_json_encode in Unknown on line 0
This error occurs because json.so must be loaded before the memcached.so is loaded, and json.so is loaded in/etc/php.d/json.ini, which causes json.so to load after memcached.so and can be removed/etc/ Php.d/json.ini file, and add extensino=json.so directly in php.ini to resolve

Configuring Memcache in =====php is these ======

10. Configure SELinux

SELinux is a set of Linux security systems that specify the disk files, network ports, and so on that the application can access.
If SELinux is installed, the default SELinux will prevent the Memcache program from accessing Port 11211, so SELinux must be configured.
Method 1: Temporarily reduce the SELinux run level so that we can test
Command: Setenforce [Enforcing | Permissive]
Enforcing indicates that a policy violation is not allowed
Permissive indicates that a policy violation is allowed but is logged
We use Setenforce Permissive

Method 2: Modify the SELinux configuration file to turn off SELinux
Edit/etc/selinux/config file, change selinux=enforcing to Selinux=disabled

Method 3: Modify the SELinux HTTP policy so that the httpd process can access the network, so you can use Memcache
Command: Setsebool-p httpd_can_network_connect true
The parameter p means to maintain the validity of the setting so that the setting remains valid after a reboot, and does not change

11. View SELinux Status

Sestatus-bv

12. Configure the Firewall

If Memcache and the Web server are not the same server, then you may also need to configure iptables
Log in to the Memcache server and get root privileges
Vi/etc/sysconfig/iptables
-A rh-firewall-1-input-p tcp-s Web server 1 IP address –dport 11211-j ACCEPT
-A rh-firewall-1-input-p tcp-s Web server 2 IP address –dport 11211-j ACCEPT
......
: Wq
/etc/init.d/iptables restart

Attached: In the Windows Development environment, you can also use the memcached

1. To http://splinedancer.com/memcached-win32/download memcache, if unable to open the link, can be downloaded at the end of this article;
2. After decompression, execute the following command in the Run box:
e:\memcached\memcached.exe-d Install
e:\memcached\memcached.exe-d start
3. Then copy the Php_memcache.dll (download at the end of this article) to the Ext folder in the System32 and PHP installation directories;
4. Add Extension=php_memcache.dll to the php.ini file;
5. Restart Apache

CENTOS6 Yum Installation 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.