Installing Memcache under CentOS

Source: Internet
Author: User

1. Install via Yum
Yum-y Install memcached

#安装完成后执行:

Memcached–h

2. Memcached operation

View Test Number Modification configuration
Vim/etc/sysconfig/memcached


The contents are as follows:
port= "11211″ #端口
User= "memcached" #用户
maxconn= "1024″ #最大内存
Cachesize= "64″ #缓存大小
Options= "" #其它选项

Can modify port, user and maximum memory, cache size

Systemctl Restart memcached #重启
Systemctl start memcached #启动
Systemctl Enable memcached #开机自启动
Systemctl status memcached #状态
Systemctl Stop memcached #关闭

3. Installing the Php-memcache Extension

Yum-y Install Php-pecl-memcache

#打开配置文件php. ini

Vim/etc/php.ini

#在里面添加扩展:

Extension=memcache.so

#重启下Apache

Systemctl Restart Httpd.service

#测试下扩展安装成功与否

Create a index.php file, and then

<?php phpinfo ();? >

Open the browser, enter the URL, if it appears as follows, the installation is successful:


# If it does not appear as shown, please continue to install Libevent-devel

Yum-y Install Libevent-devel

After this installation, no surprises, should be successful!

4. Firewall Release 11211 Port

Firewall-cmd--permanent--zone=public--add-port=11211/tcp

Proceed to here, everything is ready OK. Now, test it.

5. Testing under PHP

#建立test the. php file, write the following code:

<?php

$mem = new Memcache;

$mem->connect (' 127.0.0.1 ', 11211);

$mem->set (' Test ', "Hello world!", 0, 60);

$val = $mem->get (' Test ');

Echo $val;

?>

Then enter the appropriate URL in the browser, if everything is OK, it will appear as follows:


~

But in the process of running this program, the browser prompts: "SELinux alert Browser". Find a reason, with selinux (in this case, the SELinux will not do a deep dive). Landlord to take the measure is simple, is to close this selinux can:

Vim/etc/sysconfig/selinux

Modify the following:

Change the selinux= enforcing to selinux=disabled.

After restarting, enter the appropriate URL in the browser to see the effect as shown!

Copyright notice: Hello, everyone!

Install memcache under CentOS

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.