PHP extensions, php.ini and OPcache on Windows
Load only the extensions an app needs, keep php.ini per PHP version, tune OPcache safely and verify the loaded configuration.
- Build
- 26100.33650
- Edition
- Standard / Datacenter
- Architecture
- x64
- Support
- Documentation (E1)
- Evidence
- E1Official documentation
- Verified
- 2026-10-29
- Page type
- Task
The short answer
Section titled “The short answer”Three files matter:
php.ini— the loaded configuration;ext\— the extension DLLs;php.ini’sextension_dir— where PHP looks for them.
Verify before debugging:
php --iniphp -mphp -i | Select-String "Loaded Configuration|extension_dir"If Loaded Configuration File is not the file you edited, nothing else matters.
Extensions
Section titled “Extensions”extension_dir="ext"extension=curlextension=mbstringextension=opensslextension=pdo_mysqlextension=mysqliEnable only what the app uses. Each extension adds code and patch surface. On Windows the DLL name is usually php_<name>.dll; extension=curl resolves it under extension_dir.
If an extension fails to load, check:
- the DLL exists in
ext; - it matches the PHP version/TS-NTS/compiler;
- its dependent DLLs are present;
- the PHP error log says which one failed.
Per-version and per-site php.ini
Section titled “Per-version and per-site php.ini”With multiple PHP versions, each directory has its own php.ini. Do not copy one ini across major versions and expect the extension ABI to match.
For a site-specific ini, set PHPRC in the FastCGI environment to that directory. Keep it explicit; otherwise PHP may load C:\Windows\php.ini or a previous version’s file.
OPcache
Section titled “OPcache”opcache.enable=1opcache.memory_consumption=128opcache.max_accelerated_files=10000opcache.validate_timestamps=1opcache.revalidate_freq=2validate_timestamps=1is safe for development and small sites; PHP checks file mtimes.validate_timestamps=0is faster but requires a reload/restart after deploy; otherwise old code keeps running.- Do not enable experimental JIT “because faster” without testing the app and measuring.
Verify:
php -i | Select-String "opcache.enable|opcache.memory"A phpinfo page shows the same, but remove it after testing.
Production baseline
Section titled “Production baseline”expose_php=Offdisplay_errors=Offlog_errors=Onerror_log="C:\PHP\logs\php-error.log"date.timezone=UTCmemory_limit=256Mmax_execution_time=60upload_max_filesize=32Mpost_max_size=32Mpost_max_size must be >= upload_max_filesize, and IIS/Nginx limits must be >= both.
Verify
Section titled “Verify”php --iniphp -mphp -r "echo ini_get('memory_limit'), PHP_EOL;"Then call a page that uses the extension (PDO, curl, mbstring) instead of trusting php -m alone.
Lab boundary
Section titled “Lab boundary”E1. PHP 8.4.27 FastCGI was verified on VM 361; extension/OPcache settings were not load-tested on Server 2025.