OPcache is PHP’s built-in bytecode cache — it stores precompiled script bytecode in shared memory, eliminating the need to parse and compile PHP on every request. Enable it in php.ini: opcache.enable=1, opcache.memory_consumption=256, opcache.max_accelerated_files=20000, opcache.validate_timestamps=0 (for production — set to 1 during development). This single change can improve PHP performance by 2-5x. It’s the single most impactful optimization for any PHP application running on a VPS.
OPcache: The Essential Optimization
OPcache is PHP’s built-in bytecode cache — it stores precompiled script bytecode in shared memory, eliminating the need to parse and compile PHP on every request. Enable it in php.ini: opcache.enable=1, opcache.memory_consumption=256, opcache.max_accelerated_files=20000, opcache.validate_timestamps=0 (for production — set to 1 during development). This single change can improve PHP performance by 2-5x. It’s the single most impactful optimization for any PHP application running on a VPS.
PHP-FPM Tuning
PHP-FPM manages PHP worker processes. The key setting is pm = dynamic with appropriate values: pm.max_children controls the maximum number of workers. Calculate based on your VPS RAM: (Total RAM – OS overhead) / average PHP worker memory. For a 4GB VPS with WordPress, typically 20-30 workers. Set pm.start_servers to 25% of max_children, pm.min_spare_servers to 25%, and pm.max_spare_servers to 75%. Monitor with pm.status_path to track active/idle workers.
PHP 8.x JIT Compilation
PHP 8+ includes a JIT (Just-In-Time) compiler that can further improve performance for CPU-intensive operations. Enable with opcache.jit_buffer_size=256M and opcache.jit=1255. JIT provides the most benefit for mathematical computations and CPU-bound workloads. For typical web applications, the improvement is modest (5-15%) on top of OPcache. On Velox Media’s premium managed infrastructure with proactive performance optimization, optimized PHP delivers blazing-fast page generation.
Looking for reliable hosting? Velox Media offers Premium managed hosting and digital infrastructure for businesses that demand speed and reliability. Explore our plans and find the perfect solution for your needs.