How to enable and configure OPcache for faster PHP - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

How to enable and configure OPcache for faster PHP
==================================================

### [\#Performance](https://rocketeersapp.com/knowledge/performance)

OPcache caches compiled PHP bytecode so your code skips recompilation on every request. Here is how to enable and tune OPcache for a real production server.

 Published by [Mark van Eijk](https://rocketeersapp.com/author/mark-van-eijk) on June 23, 2026 · 1 minute read

1. [What OPcache does](#content-what-opcache-does)
2. [Check whether OPcache is enabled](#content-check-whether-opcache-is-enabled)
3. [Enable OPcache in php.ini](#content-enable-opcache-in-phpini)
4. [Key production settings](#content-key-production-settings)
5. [Development settings](#content-development-settings)
6. [Important: reset OPcache on every deploy](#content-important-reset-opcache-on-every-deploy)
7. [Restart PHP-FPM to apply changes](#content-restart-php-fpm-to-apply-changes)
8. [JIT on PHP 8](#content-jit-on-php-8)
9. [Conclusion](#content-conclusion)

OPcache is one of the biggest speedups available to a PHP app, and it costs you almost nothing to turn on. Every time PHP runs a script it normally reads the file, parses it, and compiles it to bytecode before executing. OPcache stores that compiled bytecode in shared memory, so subsequent requests skip the parse-and-compile step entirely. On a typical Laravel or WordPress app that alone can cut response times by a large margin.

[\#](#content-what-opcache-does "Permalink")What OPcache does
-------------------------------------------------------------

PHP is interpreted, but it doesn't run your source directly. It compiles each `.php` file into intermediate bytecode (opcodes) and then executes that. Without a cache, this compilation happens on *every single request*, for every file the request touches.

OPcache caches the compiled opcodes in shared memory the first time a file runs. After that, PHP fetches the bytecode straight from memory and goes directly to execution. The parsing and compilation overhead disappears, which is why enabling OPcache is usually the first PHP performance change worth making.

[\#](#content-check-whether-opcache-is-enabled "Permalink")Check whether OPcache is enabled
-------------------------------------------------------------------------------------------

OPcache ships with PHP and is often already installed, just not configured well. Check from the CLI:

 ```
php -i | grep opcache.enable

```

A clearer view comes from `opcache_get_status()`, which reports live memory usage and hit rate. Note this reflects the CLI SAPI when run from the command line; for FPM, expose it through a web script:

 ```
