Memcached is a cache system that works by temporarily storing the data you usually use in RAM. Because memory read speed is always higher than file storage, the use of memcached makes your system speed up significantly.
Memcached operation model:

In this article, I will show you how to install Memcached on CentOS 7/6/5.
Install Memcached
– Install Remi repository with CentOS 5 (CentOS 7 and 6 do not need this step)
## Remi Dependency on CentOS 5
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
– Install Memcached package:
## CentOS 7 and 6
yum install memcached
## CentOS 5
yum --enablerepo=remi install memcached
Note that two memcache packages exist: memcache and memcached (with the d at the bottom), as well as two versions of the PHP Extensions Module, php-pecl-memcache and php-pecl-memcached. We will use the second version (with the letter d) because it is stable and supports more functions.
Configure Memcached
The most important parameter to keep in mind is CACHESIZE, MB and MAXCONN. For example, underneath you use 128MB to cache (default 64MB). OPTIONS configures security only for local connect to port 11211.
# nano /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="10240"
CACHESIZE="128"
OPTIONS="-l 127.0.0.1 -U 0"
Starts Memcached
chkconfig memcached on
service memcached start
To track the memcached status, you may be able to use phpMemcachedAdmin to view it right in your browser. PHPMemcachedAdmin is just downloadable, should be installed in the management directory of HocVPS Script for security. Specifically, I will install in the directory /home/johnsmithmedia.net/private_html/
:
cd /home/johnsmithmedia.net/private_html/
wget https://github.com/elijaa/phpmemcachedadmin/archive/1.3.0.tar.gz
tar -xvzf 1.3.0.tar.gz
mv phpmemcachedadmin-1.3.0 memcached && chmod -R 777 memcached && chown -R nginx:nginx memcached
rm -f 1.3.0.tar.gz
Now you can access PHPMemcachedAdmin via domain:port/memcached/
Note: At the first time you will see the message “Error: Configuration file or folder is missing, please fix this error and try again”. You need to select Editing Configuration
then Save Live Configuration
to finish.
Install Memcache and Memcached PHP Module:
For Memcached to work with PHP, we need to install the PHP module.
yum --enablerepo=remi,remi-php55 install php-pecl-memcached php-pecl-memcache
yum --enablerepo=remi,remi-php56 install php-pecl-memcached php-pecl-memcache
yum --enablerepo=remi,remi-php70 install php-pecl-memcached php-pecl-memcache
yum --enablerepo=remi,remi-php71 install php-pecl-memcached php-pecl-memcache
service php-fpm restart
service nginx restart
Open the Memcached port (11211) on the Iptables Firewall.
In case you use a separate server to run Memcached, you need to open port 11211 on the server cache.
Use the following command:
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 11211 -j ACCEPT
service iptables restart
Install Memcached as Session Handler
You can configure PHP to use Memcached as a session handler, instead of using files, to improve the performance of your system. Of course this should only be done with source code that uses multiple sessions, no need for WordPress.
php.ini
nano /etc/php.ini
[Session]
, replace session.save_handler = files
by:[Session]
session.save_handler = memcached
session.save_path = "127.0.0.1:11211"
If using phpMyAdmin, you need to customize the application’s session storage mechanism. Edit file session.inc.php
of phpMyAdmin:
nano /home/domain.com/private_html/phpmyadmin/libraries/session.inc.php
//ini_set('session.save_handler', 'files');
_Add line :
ini_set('session.save_path', '/tmp');
service php-fpm restart
Install Memcached works with WordPress.
For Memcached to work with WordPress you need to use the W3 Total Cache plugin.

In the plugin settings section, select the page cache method Memcached for the Page Cache, Database Cache, and Object Cache modules.
Now, enjoy the speed of Memcache.
Remove Memcached
If you do not use anymore and want to completely remove Memcached from the server, run the following command:
yum remove memcached php-pecl-memcached php-pecl-memcache
service php-fpm restart
service nginx restart
7 comments
Amazing article Softweb Tuts
Great Article. Thank you for sharing! Really an awesome post for every one.
IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.
JavaScript Training in Chennai
JavaScript Training in Chennai
Finding a proper guide on CentOS is not easy, nice work !
The content is utmost interesting! I have completely enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great, and your efforts are outstanding! VPS
If you are working on a tight budget, there are several ways for you to get affordable business web hosting. Many people assume that once they get cheap hosting, they will have to deal with poor quality services. This is not always the case however. https://onohosting.com/
Web hosting determines the functionality of your website and the kind of user experience you offer your visitors. Your hosting plan ought to be reliable and should be up round the clock, but this also relies on the web host you choose and the hosting plan you choose for your business. To ensure that you end up with the best plan, there are aspects that you should consider and make sure are in place. A reliable plan is very important, especially for business websites because the last thing you want to do is chase away valuable visits. Here are a few things to think about and check when searching for a hosting plan. https://hostinglelo.in/
Artikel yang bagus, kalian dapat membaca artikel website seputar teknologi lainnya melalui laman ini TentangBerbagi dan kalian baca artikel game melalui artikel ini Point Blank