Posted 31 December, 2015
The interwebs is a bit unclear on this topic, but on a “clean” Centos 7.1 (tested on digitalocean) the PHP version is v5.4 , which is a bit of a bugger, since from v5.5 Zend Optimizer+ is included in the core of PHP, making PHP allot faster, about 70% faster for sure, if we can believe the benchmarks. I need APC not for the user cache but for the in memory storage of compiled PHP bytecode. So both Zend Optimizer+ or APC would do fine. Since Zend Optimizer is included in the PHP core of newer versions, Centos will someday push this (in the not so near future I guess). So I would recommend to use Zend Optimizer+, but feel free to ignore that advice, I am no expert. I will test both and decide then. Thought I doubt I will find much difference.
APC
If you need the user cache : yum install php-pecl-apcu
# Install APC pecl install apc #nano /etc/php.d/apc.ini extension=apc.so apc.enabled=1
restart httpd / php-fpm
You can validate that its running + stats by activating the apc.php file. Which can be found here (source).
Zend Optimizer+
yum install php-pecl-zendopcache
restart httpd / php-fpm
The config file is located : /etc/php.d/opcache.ini
There is no “official” statics script for Zend Opcache I could find, but a user (Rasmus Lerdorf) has made something similar.
wget https://raw.githubusercontent.com/rlerdorf/opcache-status/master/opcache.php
it in some public directory to see the nice stats.
FUBAR PHP v5.4
You can also ditch PHP v5.4 from Centos repo’s and add another repo, such as webtastic repo or remirepo.
If you enjoyed this article, please consider buying me a Dr Pepper.
Fuel the beast!
Buy me a Dr Pepper
[…] really low hanging fruit, such as keeping the byte-compiled PHP version of a file in memory, using Zend Opcache or the now deprecated APC. I even started thinking in some very unconventional ways, such as hybrid static rendered […]
Manually setting up caching packages on DigitalOcean server is quite a hassle, I would instead recommend some platform (like this one) for this purpose. This way you can save your time because you won’t need to bother with setting up a server or setting up caching packages on it.
Hey Oliver,
I disagree, there is a bit of (essential) Linux required to setup a LAMP stack (including caches) but if you don’t want this then a VPS might not be the best thing for you. Also Digitalocean already provides the option to instant install a LAMP stack, so I don’t see the point for such platforms …
Unless you need a ton of deployments, but even then you can automate this with cloudscripts.
[…] stuck on PHP 5.4, which does not include such caching. You have to install it manually. Thanks to this site for the […]