Do you want your website to be as fast as a Ferrari? Or are you still struggling with slow page loads like… a hibernating turtle? If so, it’s time to optimize php.ini to unlock the full potential of PHP!

In this article, we will explore key php.ini configurations that help reduce server load, speed up your website, and optimize resource usage. More importantly, all the information is based on official sources such as PHP.net, Kinsta, and WordPress Codex, along with real-world data so you can see the actual impact of each setting!
1. Locate and Edit php.ini
📌 How to find php.ini on your server
- Linux (Ubuntu/Debian):
php --ini
- Windows: Locate php.ini in your PHP installation directory (usually
C:xamppphpphp.ini
). - Check the PHP version in use:
<?php phpinfo(); ?>
Note: For Linux with PHP-FPM, you need to edit the php.ini configuration in both the CLI and FPM directories. For example, with PHP 8.2:
sudo nano /etc/php/8.2/cli/php.ini sudo nano /etc/php/8.2/fpm/php.ini
📌 Remember to restart PHP after making changes:
sudo service php8.*-fpm restart
2. Manage Script Execution Time & Server Resources
🚀 max_execution_time – Limit script execution time
- ⏳ Default: 30s
- 🔥 Recommended: 300s (or based on your application)
- 🎯 Impact: Prevents server hangs due to long-running scripts (e.g., large data imports).
max_execution_time = 300
📌 Example: Magento recommends max_execution_time = 180
to avoid timeouts during product imports [Magento Docs].
🚀 max_input_time – Limit time for processing input data
- ⏳ Default: 60s
- 🔥 Recommended: 600s (if handling large forms or file uploads)
- 🎯 Impact: Prevents prolonged request processing that can slow down the server.
max_input_time = 600
📌 Note: If set too high, attackers may exploit this for excessive requests (DoS attacks).
🚀 memory_limit – Set memory usage limits for PHP scripts
- ⏳ Default: 128M
- 🔥 Recommended:
- WordPress: 512M
- Magento: 2048M
- Laravel API: 512M – 1024M
memory_limit = 512M
📌 Real-world data: Kinsta recommends at least 512M to avoid the “Allowed memory size exhausted” error in WordPress.
3. Optimize Uploads & Data Transmission
🚀 post_max_size & upload_max_filesize – Limit data sent to the server
- 🔥 Recommended:
- Small websites: 8M
- WordPress: 64M
- E-commerce websites: 128M
post_max_size = 64M upload_max_filesize = 64M
📌 Note: post_max_size
should always be greater than or equal to upload_max_filesize
to prevent upload errors.
4. Boost PHP Performance with Opcache
🚀 Enable Opcache to speed up PHP execution
- 🔥 Reduces page load time by up to 70%.
- 🚀 A must-have for PHP 7+ performance improvements.
opcache.enable = 1 opcache.memory_consumption = 512 opcache.max_accelerated_files = 100000 opcache.consistency_checks = 0
📌 Note: If opcache.consistency_checks = 1
, performance may drop due to frequent file verification.
🚀 zlib.output_compression – Enable output compression for faster page loads
- 🔥 Recommended:
On
(except for WordPress) - 🎯 Impact: Compresses HTML/CSS/JS before sending it to the browser, reducing page size.
zlib.output_compression = On
📌 Note: WordPress already has built-in Gzip compression, so enabling this may cause conflicts.
Is PHP.ini Optimization Worth It?
Optimizing php.ini isn’t a magic fix, but it speeds up your website, reduces server load, and prevents common errors. If you want to improve performance by 50-70% without upgrading your server, this is the first step you should take.
💡 Have you applied these optimizations yet? Check your current settings with:
php -i | grep memory_limit
Are you ready to turn your website into a high-speed machine? 😎🚀