
🔍 Where is php.ini located in WordPress: finding and configuring settings
Plugin won't install, theme upload cuts off halfway? Admin panel shows "Allowed memory size exhausted"? Most often, one file is to blame: php.ini.
This is PHP's main config: it sets how much memory to allocate to scripts, how long to execute them, and what file sizes to accept. On typical hosting, these limits are set low, the host saves resources.
Below is where to find php.ini in any environment (WAMP, XAMPP, Linux, cPanel) and which five directives to edit for WordPress in 2026. With specific numbers, no guessing.
💡 Quick overview:
- Create a test PHP file with the
phpinfofunction and immediately see the path tophp.inion any server - In WAMP, XAMPP, and cPanel, the path is available through the interface, no code editing needed
- Key settings for WordPress: memory_limit, max_execution_time, upload_max_filesize, post_max_size, and max_input_vars
- After changes, check actual limits via
phpinfo()or WP-CLI to make sure the host didn't ignore modifications
What is php.ini and why touch it
php.ini is a text file with directives that control PHP's behavior on the server. It loads with every PHP process start and defines limits: memory, execution time, upload file size, error level.
For WordPress, five directives are critical. memory_limit allocates RAM for page processing, modern themes and builders (Gutenberg, Elementor) easily require 256 MB and up. max_execution_time limits seconds for script execution: if a plugin imports demo content or WooCommerce generates reports, the default 30 seconds guarantees a cutoff. upload_max_filesize and post_max_size control uploads: a theme ZIP can weigh 40+ MB, and the host's limit is 2 MB. Finally, max_input_vars limits the number of POST variables, with 1000 menu items and a default of 2000, menu saving cuts off without warning.
Good news: php.ini can be edited even on cheap shared hosting. Bad news: first you need to find it, and the path depends on operating system, control panel, and PHP installation method (Apache module, CGI/FastCGI, PHP-FPM).
How to find php.ini: universal method via phpinfo()
The most reliable way, working on any server, is to create a test PHP file with the phpinfo() function.
Create a file with any name and .php extension (for example, info.php) and put in it:
1 <?php phpinfo(); ?>
Upload the file to the site root (via FTP, hosting file manager, or WP-CLI) and open in browser: https://your-site.com/info.php.
On the opened page, find the line Loaded Configuration File, this is the full path to the active php.ini. If PHP runs as an Apache module, the path will be shown in the Configuration File (php.ini) Path line, in this case the file itself may not exist and needs to be created manually.
After checking, delete info.php immediately, it reveals server configuration details, which is unsafe.
Where is php.ini in WAMP
In WAMP (Windows build: Apache + MySQL + PHP), the path to php.ini is available right from the system tray.
Right-click the WAMP icon, hover over PHP, and select php.ini, the file will open in a text editor. If the build has multiple PHP versions, make sure you've selected the one the site runs on (visible in tray: WAMP → PHP → Version).
Alternative path via WAMP menu: left-click icon → PHP → php.ini. The file physically resides in C:\wamp64\bin\php\phpX.Y.Z\php.ini (or C:\wamp\bin\... for older versions).
Where is php.ini in XAMPP

In XAMPP on Windows and Linux, the path to php.ini is via the control panel. Open XAMPP Control Panel and click the Config button in the Apache module row. In the dropdown menu, select PHP (php.ini), the file will open in the editor.
If there's no Config button (old XAMPP version), go direct: C:\xampp\php\php.ini on Windows or /opt/lampp/etc/php.ini on Linux.
After changes, restart Apache with the Stop → Start button in the control panel.
Where is php.ini in Linux (VPS / dedicated)
On a Linux server without a control panel, php.ini is found with one terminal command:
1 php -i | grep "Loaded Configuration File"
Output will be something like:
1 Loaded Configuration File => /etc/php/8.2/cli/php.ini
Important nuance: PHP for command line (CLI) and for web server (Apache/Nginx) often use different php.ini. The command above shows the path for the CLI version. To find the path for the web server, create info.php using the method from the previous section and open in browser, or run:
1 ls /etc/php/*/apache2/php.ini 2 ls /etc/php/*/fpm/php.ini
Typical locations depend on PHP version and web server:
- Apache:
/etc/php/8.2/apache2/php.ini - PHP-FPM (Nginx):
/etc/php/8.2/fpm/php.ini - General path (if PHP is compiled manually):
/usr/local/lib/php.ini
After changes, restart the web server: sudo systemctl restart apache2 or sudo systemctl restart php8.2-fpm.
Where is php.ini in cPanel and other hosting panels

On shared hosting with cPanel, the php.ini file usually sits in the site root directory, public_html. To see it:
- Log into cPanel and open File Manager
- Navigate to the
public_htmlfolder - Find
php.iniin the file list

If the file doesn't exist, create it with the + File button. Write in the needed directives and save. The host will pick up settings within a few minutes.
On modern hosts, MultiPHP Manager (cPanel) or Select PHP Version is increasingly common, they let you edit php.ini via web interface without entering the file manager. If your panel supports such a tool, use it: less chance of syntax errors.
Separate case: .user.ini. On hosts with PHP-FPM (FastCGI), php.ini in the site root may be ignored; instead, a .user.ini file is created with the same directives. Check the host's documentation for which file to use.
Recommended php.ini settings for WordPress (current for 2026)
Basic "default" values in php.ini haven't changed in decades and are designed for simple scripts, not modern CMS. WordPress with current plugins requires significantly higher limits. Below are recommended values, tested in practice.
Core directives
Directive | Minimum | Recommended | Why |
|---|---|---|---|
| 256M | 512M | Memory per page; Gutenberg, WooCommerce, Elementor eat 128+ MB easily |
| 60 | 300 | Seconds per script; demo import, thumbnail generation, backup |
| 64M | 128M | Upload file size; themes and plugins in ZIP often weigh 20-50 MB |
| 64M | 128M | Total POST request size; must be ≥ |
| 2000 | 4000 | Number of POST variables; directly affects menu saving (50+ items = cutoff) |
| 60 | 300 | Seconds for parsing input data; |
1 memory_limit = 512M 2 max_execution_time = 300 3 upload_max_filesize = 128M 4 post_max_size = 128M 5 max_input_vars = 4000 6 max_input_time = 300 7 file_uploads = On
The safe_mode directive was removed from PHP starting with version 5.4, don't add it to configuration. If you see this line in old php.ini, delete it without hesitation.
Caching (opcache)
For production sites, opcache is mandatory, it gives a 2-3x speed boost by caching compiled bytecode:
1 opcache.enable = 1 2 opcache.memory_consumption = 256 3 opcache.max_accelerated_files = 10000 4 opcache.revalidate_freq = 2 5 opcache.validate_timestamps = 1
Error logging
On a live site, error display to screen should be off, but logging should be on:
1 display_errors = Off 2 log_errors = On 3 error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
Alternative methods:.htaccess and wp-config.php
Access to php.ini isn't always available. On some hosts, workarounds exist.
Via.htaccess (Apache + mod_php)
Add to .htaccess in the site root:
1 php_value memory_limit 512M 2 php_value upload_max_filesize 128M 3 php_value post_max_size 128M 4 php_value max_execution_time 300
This will work only if PHP runs as an Apache module (mod_php). With PHP-FPM, php_value directives will cause a 500 error, in this case use .user.ini.
Via wp-config.php
Add before the line /* That's all, stop editing! */:
1 define('WP_MEMORY_LIMIT', '512M'); 2 define('WP_MAX_MEMORY_LIMIT', '512M');
WP_MEMORY_LIMIT sets the limit for frontend, WP_MAX_MEMORY_LIMIT for admin. This doesn't replace php.ini, but often solves "Allowed memory size exhausted" precisely when server config access is restricted.
Video: finding and editing php.ini in practice
Short video with visual demonstration of all described methods, from phpinfo() to MultiPHP Manager in cPanel:
⁉️🤔 Frequently asked questions
Why did nothing change after editing php.ini?
The PHP process didn't restart. Reload Apache (
systemctl restart apache2or via panel button), PHP-FPM (systemctl restart phpX.Y-fpm), or wait for automatic restart on shared hosting (usually 2-5 minutes). Check that you're editing the exactphp.inishown byphpinfo()in the Loaded Configuration File line (one server can have several).
After changes, always check the actual limit via
phpinfo(): the host may override some directives with global settings. If the value didn't change, create.user.iniin the site root (for PHP-FPM) or contact support.
What memory_limit does WordPress really need in 2026?
256M: safe minimum for a typical site with 10-15 plugins. If a page builder is installed (Elementor, Bricks, Breakdance), WooCommerce, or a complex caching plugin, set 512M. Sites on Gutenberg with many blocks and patterns also lean toward 512M. 128M, recommended in old guides, is no longer enough for modern WordPress: core alone with a Full Site Editing theme can hit this limit.
Exception: cheap shared hosting with a hard ceiling. If the host won't raise memory_limit above 128M, consider changing plans or hosts: a site on this limit will crash with every other update.
What's more important: editing php.ini or wp-config.php?
php.iniworks at the system level,wp-config.phpat the application level. If you have access tophp.ini, edit it: limits will apply globally and won't reset on core updates. Usewp-config.phpas a fallback when the host has lockedphp.ini.WP_MEMORY_LIMITinwp-config.phpoverridesmemory_limitfromphp.inifor WordPress but doesn't affectmax_execution_time,upload_max_filesize, and other directives: those must be edited via.htaccessor.user.ini.



