Install Memcache on CentOS (WHM/cPanel)
- Step 1: Login into your WHM panel and using easyapache2 to enable Memcache.
- Step 2: SSH into your server and fire this command yum install Memcached. ...
- Step 3: Go to Software -> Module Installers -> PHP Pecl, Search for Memcache, and then install both Memcache & Memcached.
- Step 4: Restart apache once, using the command: service httpd restart
If Memcached is not available in easyapache2 then follow the below step to install Memcache via command line.
For Memcached installation on cPanel please see below step:
SSH into your server
# yum install memcached
Then, start Memcached service
# service memcached start
Example:
root@server [~]# service memcached start
Starting memcached: [ OK ]
Then, install PHP Memcache
# pecl install memcache
OR
We can install Memcache from the source by following the steps below:
# wget http://pecl.php.net/get/memcache
# cd memcache (hit tab to fill out the version number)
# phpize
Then, you can see something like this:
# phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
# ./configure
# make
#make install
Make sure the Memcache module is present in the php.ini file. If not, add the Memcache extension in the php.ini file.
# echo "extension=memcache.so" >> /usr/local/lib/php.ini
Finally, restart Apache
# service httpd restart
Make sure Memcached will be up even after a server reboot:
# chkconfig --levels 235 memcached on
How to check if Memcache is installed or not?
root@server [~]# php -m | grep memcache
memcache
All Done! If everything goes well, You should now be able to use Memcached within your application.