OPcache. Best configuration for 10+ websites

OPcache. Best configuration for 10+ websites
OPcache. Best configuration for 10+ websites

I published post about my PHP 7 installation. There no need Alternative PHP Cache (APC) anymore because there has very good PHP accelerator OPcache. Moreover APC doesn’t compatible with PHP 5.5 and older. By the way, if you are first time heard about OPcache, then:

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. PHP.net

PHP.net

I have more than 10 websites on my server. And today I would love to share my OPcache. Best configuration for 10+ websites configuration. In my opinion and my experience there is best configuration.

First of all I want show you how’s it works. I didn’t restart server for few days.

OPcache
Free memory: 322.08MB of 512.00MB. Zero wasted
OPcache
Free keys: 10031 of 16229
OPcache
Hits: 99.68%

And now I’m sharing my OPcache configuration

zend_extension=opcache.so
opcache.enable=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=4
opcache.max_accelerated_files=16229
opcache.max_wasted_percentage=5
opcache.use_cwd=1
opcache.validate_timestamps=0
opcache.save_comments=1
opcache.load_comments=1
opcache.fast_shutdown=1
opcache.blacklist_filename=/etc/php.d/оpcache*.blacklist
opcache.max_file_size=0
opcache.consistency_checks=0
opcache.force_restart_timeout=180

You can copy and past or download my configuration file opcache.ini from Google Drive.

You can read more about OPcache runtime configuration .

In Ubuntu Server the file is here:
/etc/php5/conf.d/opcache.ini

In CentOS is here:
/etc/php.d/opcache.ini

Don’t forget restart Apache in Ubuntu:
sudo /etc/init.d/apache2 restart

In CentOS:
service httpd restart