centos memcached php 5.2.17 ius repo
- font size decrease font size increase font size
- Print Email
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:
- MAXCONN : Set 1024 max simultaneous connections. For high traffic websites increase this value as per requirement.
- CACHESIZE : Set 512MB max memory. For high traffic websites you can set it to 1GB.
- 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.
( ! ) 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 | ||||
# | Time | Memory | Function | Location |
1 | 0.0027 | 413792 | {main}( ) | .../index.php:0 |
2 | 0.1584 | 4718376 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.1584 | 4718376 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.6044 | 12446400 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.6051 | 12470808 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.6065 | 12526136 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.6072 | 12554960 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.6202 | 12990368 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.6202 | 12990368 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.6361 | 13715568 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.6361 | 13715568 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.6417 | 14111936 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.6460 | 14132304 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.7625 | 17158208 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.7625 | 17158208 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.7695 | 17338408 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |
- Published in CentOS 6
- Read 1932 times
( ! ) 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 | ||||
# | Time | Memory | Function | Location |
1 | 0.0027 | 413792 | {main}( ) | .../index.php:0 |
2 | 0.1584 | 4718376 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.1584 | 4718376 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.6044 | 12446400 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.6051 | 12470808 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.6065 | 12526136 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.6072 | 12554960 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.6202 | 12990368 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.6202 | 12990368 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.6361 | 13715568 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.6361 | 13715568 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.6417 | 14111936 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.6460 | 14132304 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.7625 | 17158208 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.7625 | 17158208 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.7695 | 17338408 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |