centos memcached php 5.2.17 ius repo

1 安装 IUS repo  自动打开  rpel

 

2.

yum install -y memcached

 

3.

yum install -y gcc make 

 

4.

service memcached start
chkconfig memcached on

pecl install memcache

 

5

php.ini

添加 

 

extension="memcache.so"

 

 

 

Configure Memcached

The most important value to configure is CACHESIZE. For example following configuration shows 512MB memory for Memcached. Edit /etc/sysconfig/memcached file, enter:

# vi /etc/sysconfig/memcached

Sample Output:

PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="512" OPTIONS=""

For high traffic websites you need to increase the following values:

  1. MAXCONN : Set 1024 max simultaneous connections. For high traffic websites increase this value as per requirement.
  2. CACHESIZE : Set 512MB max memory. For high traffic websites you can set it to 1GB.
  3. OPTIONS : Set server IP address so that Apache/php/nginx based server can connect to the server.

My sample updated file:

PORT="11211" USER="memcached" MAXCONN="4096" CACHESIZE="512" OPTIONS="-l 192.168.1.1"

 

How To Start and Stop Memcached

Try the all following commands:

# chkconfig memcached on
# /etc/init.d/memcached start
# /etc/init.d/memcached stop
# /etc/init.d/memcached restart
# /etc/init.d/memcached status

 

Verify Memcached is Running and Working

Run following command to verify if it is running or not.

# netstat -tulpn | grep :11211

Sample Output:

 tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 19796/memcached tcp 0 0 :::11211 :::* LISTEN 19796/memcached udp 0 0 0.0.0.0:11211 0.0.0.0:* 19796/memcached udp 0 0 :::11211 :::* 19796/memcached 

Use the memcached-tool to get general stats of server:

# memcached-tool 192.168.1.1 stats

 

Configure Firewall for Memcached

Protect memcached server by allowing access to your own servers. Edit/etc/sysconfig/iptables and append the following rules.

## only accept connection to tcp/udp port 11211 if ip is between 192.168.1.1 and 192.168.1.10 ##
# iptables -A INPUT -p tcp --destination-port 11211 -m state --state NEW -m iprange --src-range 192.168.1.1-192.168.1.10 -j ACCEPT
# iptables -A INPUT -p udp --destination-port 11211 -m state --state NEW -m iprange --src-range 192.168.1.1-192.168.1.10 -j ACCEPT

 

Restart Iptables Firewall

Type the following command to restart iptables.

# service iptables restart
## OR ##
# /etc/init.d/iptables restart

 

Test Remote Connection

Try the following command from remote server to test Memcached is listening or not.

# echo stats | netstat 192.168.1.1 -tulpn | grep :11211

Sample Output:

 tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 19796/memcached tcp 0 0 :::11211 :::* LISTEN 19796/memcached udp 0 0 0.0.0.0:11211 0.0.0.0:* 19796/memcached udp 0 0 :::11211 :::* 19796/memcached 

 

Install Memcached PHP Module

 

# yum install php-pecl-memcache

 

Install Memcached Perl Module

 

# yum install perl-Cache-Memcached

 

Install Memcached Python Module

 

#  yum install python-memcached

 

Restart Web Server

 

# /etc/init.d/httpd restart
## OR ##
service httpd restart

For more information visit memcached project.

Last modified onSaturday, 05 January 2013 13:10

( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169
Call Stack
#TimeMemoryFunctionLocation
10.0027413792{main}( ).../index.php:0
20.15844718376Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.15844718376Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.604412446400Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.605112470808Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.606512526136Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.607212554960require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.620212990368K2ControllerItem->execute( ).../k2.php:64
90.620212990368K2ControllerItem->display( ).../BaseController.php:710
100.636113715568K2ControllerItem->display( ).../item.php:78
110.636113715568K2ControllerItem->display( ).../controller.php:19
120.641714111936Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.646014132304K2ViewItem->display( ).../ViewController.php:102
140.762517158208K2ViewItem->display( ).../view.html.php:742
150.762517158208K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.769517338408include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701

( ! ) Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
Call Stack
#TimeMemoryFunctionLocation
10.0027413792{main}( ).../index.php:0
20.15844718376Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.15844718376Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.604412446400Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.605112470808Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.606512526136Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.607212554960require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.620212990368K2ControllerItem->execute( ).../k2.php:64
90.620212990368K2ControllerItem->display( ).../BaseController.php:710
100.636113715568K2ControllerItem->display( ).../item.php:78
110.636113715568K2ControllerItem->display( ).../controller.php:19
120.641714111936Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.646014132304K2ViewItem->display( ).../ViewController.php:102
140.762517158208K2ViewItem->display( ).../view.html.php:742
150.762517158208K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.769517338408include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701
back to top