How to Install PHP OPCache APC/APCu Memcached and Redis on VestaCP CentOS

by Sandy

In this tutorial we’ll implement and install various type of opcache and object cache in order to increase the performance of your websites and lower the loads for server.

OPCache and object cache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.

In other words, a PHP script when it is executed, is compiled into opcode/object cache (memcache and redis), code that is understandable by the machine. OPCache and object cache stores this code into memory on the first execution, to be reused afterwards, thus leading to performance boosts.

Lets get Started :

First install Remi repo :

CentOS 7

wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm

CentOS 6

wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm

To install Zend Opcache :

OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.

yum install php-opcache

After installation you need to restart Apache/php-fpm :

if you’re using Apache (mod_php) :

service httpd restart

If you’re using PHP-FPM :

service php-fpm restart

To install APC/APCu :

APC is a free, open, and robust framework for caching and optimizing PHP intermediate code.

yum install php-pecl-apcu

After installation you need to restart Apache/php-fpm :

if you’re using Apache (mod_php) :

service httpd restart

If you’re using PHP-FPM :

service php-fpm restart

To install Memcached :

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

For PHP 5.xx

yum install memcached memcached-devel php-pecl-memcache

For PHP 7.xx

yum install memcached memcached-devel php-pecl-memcached

Start memcached Service :

service memcached start

Start the memcached on boot :
Centos 6 :

chkconfig memcached on

Centos 7 :

systemctl enable memcached

After installation you need to restart Apache/php-fpm :

if you’re using Apache (mod_php) :

service httpd restart

If you’re using PHP-FPM :

service php-fpm restart

To install Redis :

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.

yum install redis php-pecl-redis

Start Redis Service :

service redis start

Start the Redis on boot :
Centos 6 :

chkconfig redis on

Centos 7 :

systemctl enable redis

After installation you need to restart Apache/php-fpm :

if you’re using Apache (mod_php) :

service httpd restart

If you’re using PHP-FPM :

service php-fpm restart

Also Check : How to Optimize Nginx and PHP-FPM VestaCP CentOS

If this post helps you in any way please consider a donation

Donate with PayPal :

md-donate

Donate with Paytm :

md-donate

You may also like

6
Leave a Reply

avatar
2 Comment threads
4 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
SandyHitesh L.Roy Gomez Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Roy Gomez
Guest
Roy Gomez

Hello!
Nice tutorial. Can you also provide instructions on how to use each of these in wordpress?

Roy Gomez
Guest
Roy Gomez

Can I use two different object cache for a single wordpress site?

Memcached Redux for memcached.
Redis object cache for redis.

Is is possible to use both of them on the same wordpress site?