Enable and use php opcache.
Published on 14.09.2014
While APC was the one of most used php cache from version 5.4 PHP has a built opcode cache. Without this type of caching every user "hit" invoke runtime compiler which is generate intermediate code and then execute it. The role of cache engine is to generate and save intermediate code into shared memory. In fact we don't need to generate same and same intermediate code if it's not changed from last execution. Using a opcache will cause dramatic performance speedup and will reduce memory consumption on server side.
For using builtin opcache in php we must edit
php.inifile and remove some comments like this:
[opcache] opcache.enable=1 opcache.enable_cli=0 opcache.memory_consumption=64 opcache.max_accelerated_files=2000 opcache.validate_timestamps=1 opcache.revalidate_freq=0 opcache.save_comments=0 opcache.load_comments=0 opcache.fast_shutdown=1and after that just restart php5-fpm process for nginx servers or if you are using apache2 restart apache server:
service php5-fpm restartThat is :)
You can check if it's enabled by typing
php -vand result must be like:
root@eureka:~# php -v PHP 5.5.9-1ubuntu4.4 (cli) (built: Sep 4 2014 06:56:34) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend TechnologiesIf you want to watch simple stats about opcache you can check this script https://github.com/rlerdorf/opcache-status/blob/master/opcache.php
For more information about opcache visit https://wiki.php.net/rfc/optimizerplus