Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Enable OPcache in the configuration loaded by PHP-FPM, not just the command-line PHP installation. Confirm that the extension is loaded, add a suitable OPcache baseline to the FPM SAPI’s php.ini or scanned .ini file, make Nginx pass requests to the intended FPM socket, restart the FPM workers, and verify the result through a web request. Nginx itself does not turn OPcache on; it forwards PHP requests to PHP-FPM through FastCGI.

The procedure below separates CLI checks from the web SAPI, keeps edited files fresh during development, and gives production deployments an explicit cache-invalidation strategy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What OPcache does—and what Nginx and PHP-FPM do

OPcache is a PHP extension that stores precompiled PHP bytecode in shared memory. Without it, PHP repeatedly loads and parses source scripts as requests arrive. With it, workers can reuse compiled scripts until a file changes or the cache is reset.

The request path has three separate responsibilities:

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
  • Nginx accepts the HTTP request and passes PHP requests to a FastCGI server.
  • PHP-FPM owns the PHP workers and the PHP configuration used by those workers.
  • OPcache runs inside those PHP workers and stores compiled bytecode in their shared memory.

That division explains the most common mistake: php --ini and php -m inspect the CLI SAPI. A browser request may use a different PHP version, a different php.ini, or a different extension directory through FPM. Always verify the final state through the same Nginx server block and FPM pool that serve the application.

OPcache is also different from Nginx response caching. OPcache stores compiled PHP code; Nginx fastcgi_cache stores complete HTTP responses. They have different invalidation rules and can be enabled independently.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before changing configuration

Have shell access with permission to read PHP and Nginx configuration, edit the FPM configuration, and restart the relevant service. Record the PHP version used by the application and identify whether FPM communicates through a Unix socket or a TCP address. Make a copy of any configuration file before editing it.

Use a temporary diagnostic endpoint only on a protected development or administration path. A page containing phpinfo() exposes paths, modules, environment variables and server details; remove it as soon as verification is complete.

1. Identify the PHP-FPM configuration and extension

Use CLI commands as an initial inventory

Run these commands to see what the command-line SAPI knows:

php --ini
php -m | grep -i opcache

The first command prints the CLI configuration file and scanned directory. The second reports whether the CLI extension is loaded. These results are useful clues, but they do not prove that the browser-facing FPM SAPI is configured the same way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inspect the FPM SAPI from a web request

Create a temporary PHP file in the document root, for example opcache-check.php:

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
<?php
header('Content-Type: text/plain');
var_dump(opcache_get_status(false));
phpinfo();

Request it through the real hostname and server block. In the output, note Loaded Configuration File, every directory listed under Scan this dir for additional .ini files, the PHP version, and the OPcache section. Those values identify the files PHP-FPM actually reads.

After you know the configuration, delete the endpoint. If you need a lower-exposure check, use a temporary script that prints only selected values:

<?php
header('Content-Type: text/plain');
$status = function_exists('opcache_get_status') ? opcache_get_status(false) : false;
var_dump([
    'opcache.enable' => ini_get('opcache.enable'),
    'opcache.revalidate_freq' => ini_get('opcache.revalidate_freq'),
    'status' => $status ? $status['opcache_enabled'] : false,
]);

This still must be removed after testing.

Load the extension only once

If OPcache was built as a shared extension and is not already loaded, PHP documents loading it with a zend_extension directive:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
zend_extension=/full/path/to/opcache.so

Packaged Linux installations commonly enable OPcache in a vendor-provided .ini fragment. Check the FPM SAPI’s loaded configuration before adding this line. A duplicate loader can produce startup warnings or prevent PHP from starting cleanly. If the extension is absent, install the OPcache package that matches the FPM PHP version, then repeat the web-SAPI check.

2. Add a conservative OPcache baseline to the FPM configuration

Edit the php.ini reported by the FPM diagnostic, or an OPcache-specific .ini file in the FPM SAPI’s scanned directory. PHP-FPM uses normal php.ini syntax. Do not place these directives only in the CLI configuration.

; Place in the php.ini or OPcache .ini file read by PHP-FPM
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.validate_timestamps=1
opcache.revalidate_freq=2
opcache.save_comments=1

The PHP manual currently lists 128 MB for opcache.memory_consumption, 8 MB for opcache.interned_strings_buffer, 10,000 for opcache.max_accelerated_files, enabled timestamp validation, and a two-second revalidation interval as directive defaults. These are starting points, not a capacity guarantee for every application.

Directive Purpose How to choose it
opcache.enable Enables opcode caching for the SAPI. Set to 1 for the FPM workers that serve the application.
opcache.memory_consumption Shared memory available for cached bytecode. Increase only when status output shows the cache approaching its limit; account for the memory available to all FPM workers and other services.
opcache.interned_strings_buffer Memory reserved for interned strings. Use the baseline first, then adjust based on the application and observed status.
opcache.max_accelerated_files Maximum number of scripts that can be cached. Choose a limit above the application’s PHP-file count, including vendor code, without setting an arbitrary value merely to make the number larger.
opcache.validate_timestamps Controls whether OPcache checks source-file timestamps. Keep it enabled while developing; disable it only when deployment always resets or replaces the cache.
opcache.revalidate_freq Seconds between timestamp checks when validation is enabled. A short interval favors freshness; a longer interval reduces filesystem checks. A value of 0 checks on every request.
opcache.save_comments Retains comments and docblocks in cached scripts. Keep it enabled unless the application is known not to use annotations. PHP warns that removing comments can break frameworks and tools that parse docblocks.

PHP’s installation guidance also shows a deployment-oriented example using opcache.max_accelerated_files=4000 and opcache.revalidate_freq=60. That example is not a universal recommendation: select values from the application’s file count and release process rather than copying it unchanged.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Check whether the cache is large enough

After the first restart and normal application traffic, inspect opcache_get_status(). Look for the cache’s total and used memory, the number of cached scripts, and the configured upper limit. If the cache fills, PHP may report wasted memory or stop caching additional files; increase capacity only after confirming the limit is the cause. A larger cache consumes real shared memory and does not improve an application that has few scripts.

3. Ensure Nginx sends PHP files to the intended FPM pool

A minimal Nginx location has the same core responsibilities as the official FastCGI example:

location ~ .php$ {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    fastcgi_index index.php;
}

Replace the socket with the path exposed by the installed FPM pool. A pool can instead listen on a TCP endpoint such as 127.0.0.1:9000:

fastcgi_pass 127.0.0.1:9000;

The PHP version and socket filename in these examples are placeholders. Inspect the pool configuration and the service status to find the live endpoint. The Nginx worker must be able to connect to a Unix socket, including any required group permissions.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep the script filename safe

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; tells FPM which file to execute. Make sure $document_root is the intended application directory and that the location does not pass arbitrary, nonexistent or user-controlled paths to PHP. An incorrect filename commonly causes “Primary script unknown” errors; an overly broad PHP location can expose files that should never be executed.

Test Nginx before reloading

Validate the syntax first:

nginx -t

Only after a successful test, reload Nginx so it rereads the server configuration. Reloading Nginx does not reload OPcache inside existing PHP-FPM workers; the FPM workers must be restarted or otherwise recycled for process-level OPcache configuration changes to take effect.

4. Apply the settings and verify them through the web SAPI

  1. Reload Nginx after nginx -t succeeds.
  2. Restart or reload the matching PHP-FPM service with the host’s service manager. A restart is the reliable choice after changing OPcache directives because it replaces workers that already hold the old configuration. Service names vary by distribution and PHP version; use the installed unit rather than assuming a particular name.
  3. Request the temporary diagnostic endpoint through the same hostname and server block as the application.
  4. Confirm that opcache.enable is 1, opcache_get_status() reports an enabled cache, and the reported memory, file limit and revalidation settings match the FPM configuration.
  5. Make a harmless application request and inspect the Nginx and PHP-FPM logs. FastCGI connection failures, permission errors and script-filename errors usually indicate routing or service problems rather than an OPcache directive problem.
  6. Delete the diagnostic file and clear any access-control exception created for it.

If the browser still reports a disabled cache, check that the request reached the expected FPM pool. Multiple PHP versions, server blocks and sockets can make a correct edit appear ineffective when traffic is routed elsewhere.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Development and production settings are different decisions

Development: prioritize freshness

Keep opcache.validate_timestamps=1 while developing. OPcache then checks whether source files changed at the configured interval. Set opcache.revalidate_freq=0 when immediate visibility of every edit matters; a short nonzero interval reduces filesystem checks while still detecting changes automatically.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If an edit is not visible during development, do not assume the browser is caching the page. Check the FPM SAPI values first, then confirm that the request is reaching the expected pool and that workers were restarted after changing configuration.

Production: choose an explicit invalidation method

For a release process that atomically replaces the complete application tree, a team may set opcache.validate_timestamps=0 to avoid timestamp checks. PHP documents the consequence: changed files will not take effect until OPcache is reset, individual scripts are invalidated, or the web workers are restarted.

A production deployment must therefore contain a deterministic cache step. The usual options are:

  • Restart the matching PHP-FPM workers after publishing the new release.
  • Run a controlled operation that calls opcache_reset() for the relevant cache.
  • Invalidate selected scripts with opcache_invalidate() when the deployment system can identify exactly what changed.

Do not expose reset functions through an unauthenticated web URL. Run them from a restricted deployment mechanism or use the FPM restart approach. If the release process can leave old and new files mixed in one tree, do not disable timestamp validation without first fixing that deployment risk.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Concern Development profile Production profile
Source freshness Timestamp validation enabled; recheck immediately or at a short interval. Validation can be longer or disabled only when every release performs an invalidation step.
Deployment action Edits are discovered automatically. Restart FPM or reset/invalidate OPcache as part of the release.
Compatibility Retain comments and docblocks unless the project proves they are unnecessary. Use the same compatibility setting; performance tuning is not a reason to remove annotations blindly.
Verification Check the web SAPI after configuration edits. Check the new release with a web request and review FastCGI and FPM logs.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

“CLI says enabled, but the browser says disabled”

CLI and FPM can load different configuration files, extension directories and PHP versions. Use the temporary web diagnostic to read the FPM Loaded Configuration File, scanned .ini directory, PHP version and OPcache status. Edit that configuration, restart the matching FPM service, and test through the application’s server block. Do not try to solve an FPM mismatch by editing the CLI php.ini repeatedly.

“I changed a PHP file, but the old code still runs”

Check opcache.validate_timestamps and opcache.revalidate_freq in the web SAPI. With validation disabled, a filesystem change is intentionally invisible until you reset OPcache, invalidate the script or restart the FPM workers. With validation enabled, wait for the configured interval, then verify that the request is reaching the expected document root and release directory.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

“A 502 Bad Gateway appeared after changing Nginx”

A 502 generally means Nginx cannot reach the FastCGI endpoint. Confirm that the FPM service is running, that fastcgi_pass names its live Unix socket or TCP address, and that the Nginx worker has permission to use a Unix socket. Check both Nginx’s error log and the FPM service log. If the socket filename contains a PHP version that is no longer installed, update the location to the active pool and reload Nginx after a successful syntax test.

“Primary script unknown” or the wrong file executes

Inspect SCRIPT_FILENAME, $document_root, the server block selected for the hostname, and the actual release path. The file must exist where FPM expects it, and the FPM user must be able to traverse its directories and read it. Tighten the PHP location so only intended PHP files are passed to FPM; never use a document-root expression that can be manipulated into an arbitrary filesystem path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“Framework annotations stopped working”

Keep opcache.save_comments=1. Some frameworks and command-line tools inspect docblock annotations at runtime. If comments were disabled, restore the setting and restart FPM so newly cached scripts retain them.

“The extension fails to load or PHP will not start”

Look for duplicate zend_extension lines, a path that does not exist, or a module built for a different PHP version. Remove the duplicate loader, install a matching module, or correct the path in the FPM-scanned configuration. Validate the configuration and inspect the service log before sending traffic back to the pool.

Capacity, pools and monitoring

OPcache memory is shared by the PHP-FPM workers using a cache. The configured memory size must be large enough for the application’s compiled scripts and interned strings, but allocating more does not automatically make requests faster. Consider the total memory budget of the host, the number of FPM pools, and whether separate pools use separate caches in your PHP build and operating-system packaging.

Monitor the values returned by opcache_get_status() during normal traffic: enabled state, used and free memory, cached-script count, restart indicators and wasted-memory information. A cache that repeatedly reaches its file or memory limit needs capacity planning; a cache with ample free space does not justify arbitrary increases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

There is no universal percentage speed-up established by the official configuration documentation. Treat the published directive values as configuration defaults and measure your own application if you need a performance decision. Compare like-for-like requests, keep deployment and database conditions constant, and record whether the test used a warm cache.

Operational checklist

  • Confirm the PHP version and FPM pool serving the application.
  • Use php --ini and php -m only as CLI inventory checks.
  • Read the FPM configuration from a temporary, protected web diagnostic.
  • Ensure OPcache is loaded once, not duplicated across scanned .ini files.
  • Set the baseline directives in the FPM SAPI configuration.
  • Keep comments when the application or its tools use annotations.
  • Verify fastcgi_pass and SCRIPT_FILENAME in the Nginx server block.
  • Run nginx -t before reloading Nginx.
  • Restart the matching FPM workers after OPcache configuration changes.
  • Verify status through the application’s web path, then remove diagnostic files.
  • Document whether releases restart FPM, reset OPcache or invalidate individual scripts.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.