This is a guide on how to install Zend OPcache on Ubuntu Server with PHP 5.4. As we found it hard to find any useful info on how to install it, here is a simple guide. If you have PHP 5.5 or higher it’s already included in the system.
The Zend OPcache provides faster PHP execution through opcode caching and optimization. It improves PHP performance by storing precompiled script bytecode in the shared memory.
Note: Check for latest version here. Change 7.0.4 to the latest build.
1. Pecl Install
Write this in your terminal:
:~$ sudo pecl install zendopcache-7.0.4
2. Find where opcache.so is located
:~$ sudo find / -name 'opcache.so'
Use the output in step 3.
3. Add the extension to PHP.ini
Add this line in your php.ini file that you find in /etc/php5/apache2
3. Test your new config
You should only have to ask for PHP version in the terminal by typing
:~$ php -v
And the output should then look something like this
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.4, Copyright (c) 1999-2014, by Zend Technologies
But if that DOESN’T work, you can always do like this
Make a file with www-data permissions called phpinfo.php and place it in /var/www/phpinfo.php
<?php phpinfo(); ?>
Access phpinfo.php from the http://your-default-domain.com/phpinfo.php and check for this
If you find this in you phpinfo.php then your successfully installed Zend OPcache.