• Home
  • About Us
  • Contact
  • Privacy Policy

LinuxAdmin.io

  • Home
  • Tutorials
    • System Administration
    • Linux Tutorials
    • Web Hosting
    • WordPress
    • Virtualization
    • Troubleshooting
    • OpenStack

Setup and Optimize Zend OpCache

Zend Opcache

Zend OPCache:

Zend OpCache is a caching engine that comes with PHP by default in later releases (PHP 5.5 and above).  It is a caching engine that stores precompiled php code in memory which ultimately results in performance increase as the code does not have to be fully recompiled on each new request.  The degree to which these performance improvements are noticeable depends on how busy your site is.  The busier your site, the more noticeable.

To utilize opcache, you need to have a PHP installation, if you do not please see Compiling PHP From Source

Install Instructions:

If you have a php release before 5.5 you install Opcache with the PECL:

pecl install opcache

Then add the following line to php.ini

extension="opcache.so"

If you are not sure where your php.ini to the following to locate it:

# php -i|grep 'Loaded Configuration'
Loaded Configuration File => /etc/php.ini

Finally restart the web server to load it.

Performance Tuning:

opcache.revalidate_freq – This is how often to check php scripts timestamps for updates. Setting this to 0 will result on opcache checking every time for updates on the script.

opcache.validate_timestamps – If this is enabled, this will check php scripts based on the revalidate_freq to check for updates.  If this is disabled it  wont check for updates at all.

opcache.max_accelerated_files –  The number of scripts that can be in the hash table. There should be less scripts than what this number is set to. To find the total amount of php files do the following:

find /path/to/web/dir -type f -name "*.php"|wc -l

opcache.memory_consumption – Size of the shared memory storage used by the cache in MB.  This is how much memory the cache is allowed to consume.

opcache.interned_strings_buffer – The amount of memory used to store interned strings in MB. This is basically compression for php, If you use the same strings multiple places it stores it once and then uses pointers when its used other places.

opcache.fast_shutdown – Allows for faster shutdown

Suggested values:

You can place the following in your php.ini and restart the webserver to load the performance settings:

opcache.revalidate_freq=0
opcache.validate_timestamps=0 (if disabled it wont check at all)
opcache.max_accelerated_files= (use the find example above)
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.fast_shutdown=1

You can find more explanation here

 

 

Apr 23, 2017LinuxAdmin.io
2.8 8 votes
Article Rating
Compiling PHP from source on CentOSKVM installation on CentOS
You Might Also Like
 
Nginx Caching for WordPress using fastcgi_cache
 
Nginx Load Balancing
Subscribe
Notify of
guest
guest
0 Comments
Inline Feedbacks
View all comments
5 years ago Apache, Linux Tutorials, PHP, Web Hosting Linux Performance Tuning46,685
Recent Posts
  • Laravel Installation Guide For CentOS
  • Openstack Services Explanation And Overview
  • OSSEC Intrusion Detection Installation On Centos 7
  • Configure ProFTPd for SFTP on CentOS
  • How To Check And Repair MyISAM Tables In MySQL
Most Commented
Hot Clone Linux Server with Rsync
Hot Clone A CentOS Server With Rsync
14 Comments
ngx_cache_purge module
Install The ngx_cache_purge Module In Nginx
8 Comments
piwik-nginx
Piwik Analytics on Nginx
8 Comments
Tags
linuxcentosLinux Performance Tuningsysadminkvmnetworkingmemcachedanalyticssystemd
About

We love Linux and are dedicated to creating Linux administration tutorials for System Administrators since 2016.

Most Viewed
Default Gateway
How To Configure A Default Gateway on CentOS
61,492 views
Zend Opcache
Setup and Optimize Zend OpCache
46,685 views
Install ffmpeg
FFMpeg Install On CentOS 7
20,842 views
Archives
Email subscription

Sign up for our newsletter to receive the latest news and event postings.

2018 © LinuxAdmin.io
wpDiscuz