1. Home
  2. Blog
  3. Where Is the php.ini File in WordPress?

Where Is the php.ini File in WordPress?

In WordPress, the php.ini file is on the server, not in the WordPress folder; the “Loaded Configuration File” line in the phpinfo() output or the php --ini command over SSH shows its full path. In this guide, we explain how to find the file on cPanel, Plesk, SSH and shared hosting, how to use .user.ini and which settings we recommend.

By meomanWordPress since 2008

What Is php.ini and Why Does It Matter for WordPress?

php.ini is PHP’s main configuration file and sets the limits for memory, file uploads and execution time; it lives on the server, not in the WordPress folder. The “Loaded Configuration File” line in the phpinfo() output shows its full path: on Ubuntu / Debian servers this is usually /etc/php/8.x/fpm/php.ini, and on cPanel (EasyApache) servers it is a path such as /opt/cpanel/ea-php83/root/etc/php.ini. If you cannot edit this file on shared hosting, use the MultiPHP INI Editor in cPanel or the .user.ini file in your site’s root directory.

The default PHP limits are often too low for WordPress. Low file upload limits can prevent you from uploading high-resolution media files or large plugin packages. Short execution times can also cut off database backups halfway through. That is why knowing where the file is and being able to adjust it when needed is a technical must.

From a security standpoint, disabling certain PHP functions in php.ini protects your site against malicious attacks. Turning off error display (display_errors) on live sites prevents attackers from learning about your server’s structure. Together, these technical details keep your WordPress site running both fast and securely.

  • It allocates server resources (RAM and CPU) to PHP applications.
  • It sets file upload and data transfer limits to keep the system from getting clogged.
  • It lets you restrict specific PHP functions to close security gaps.
Access MethodDefault File PathUse CaseDifficultyLevel of Control
SSH / Terminal/etc/php/8.x/fpm/php.iniVPS and Dedicated ServersHighFull Control
cPanel File Managerphp.ini or .user.ini in public_html (local settings)Shared hostingLowLimited Control
FTP / SFTPRoot DirectoryFile Transfer and EditingMediumModerate
phpinfo() FunctionBrowser OutputLocating the FileVery lowView Only
Plesk PanelPHP Settings TabManaged via the PanelLowWithin Panel Limits

The Fastest Method: Finding the Location with a phpinfo.php File

The most accurate way to find exactly where php.ini is on your server is to use a small PHP script. Hosting companies sometimes place the file in non-standard directories, and when several PHP versions are installed, it can be hard to tell which file is active. When you write a simple line of PHP in a text editor and upload it to your server, the server shows you all its configuration details in a table.

To use this method, you need access to your site’s root directory (usually public_html). Create a file named “phpinfo.php” via an FTP client or your panel’s file manager, add the code and then open the file in your browser. Search the page for the “Loaded Configuration File” line to see the full path of the php.ini file in use. Because this method reports the system’s actual state instead of relying on guesswork, it eliminates the margin of error.

Once you are done, deleting this file from the server is vital for security. The file exposes sensitive information such as your server’s PHP version, installed modules and directory structure to anyone. Current security practice strongly recommends never leaving files that disclose this kind of information on a server.

  1. Create a text file and paste the code <?php phpinfo(); ?> into it.
  2. Save the file as phpinfo.php and upload it to your site’s root directory.
  3. Go to yourdomain.com/phpinfo.php in your browser and find the “Loaded Configuration File” entry.

Accessing php.ini Through cPanel and Plesk

Modern hosting panels offer visual interfaces so users can change PHP settings without touching code. On a cPanel server, the “MultiPHP INI Editor” tool in the “Software” section gives you direct access to php.ini. With it, you choose which domain you want to change settings for and update the values from a list. This method is ideal for users who do not want to bother finding the file path.

In Plesk, the process works a little differently. When you open the “PHP Settings” section in the domain management panel, you can change many parameters to the extent the server allows. Rather than letting you edit the settings as a file, Plesk usually has you enter values through a form. However, the advanced options include a field where you can add custom directives. These panels automatically write your changes to the file in the right directory or create additional configuration files such as .user.ini.

If you do not see these tools in your panel, your hosting provider may have restricted this permission. In that case, turn on the option to show hidden files in the file manager’s root directory. Sometimes a php.ini file does not exist by default; if so, you can create a new file in the same directory, name it php.ini and start defining your own custom settings.

  • Use the “MultiPHP INI Editor” tool in cPanel to edit settings visually.
  • Update the predefined limits in the “PHP Settings” tab in Plesk.
  • Turn on hidden files in the file manager and look for php.ini or .user.ini in the root directory.
Related serviceSupport & Consulting

Finding the File Path with SSH and the Command Line

If you manage your own VPS (virtual private server) or dedicated server, using the terminal is much faster and more effective than graphical interfaces. Once you connect to your server via SSH, PHP’s command-line interface (CLI) can tell you where the file is within seconds. There is one thing to watch out for, though: PHP’s CLI version and the version used by the web server (Apache/Nginx) may use different php.ini files. That is why using the right command is critical.

When you run the php --ini command in the terminal, the system lists the paths of the configuration files. The php -i | grep "Loaded Configuration File" command, however, also shows only the file used by the command line (CLI); to see the file read by the web server (PHP-FPM or the Apache module), check the phpinfo() page. On Ubuntu and Debian, php.ini files live under the /etc/php/ directory in the folder for the relevant PHP version; on systems such as AlmaLinux / CentOS, the path is usually /etc/php.ini. For example, if you use PHP 8.4, the file path will most likely be /etc/php/8.4/fpm/php.ini or /etc/php/8.4/apache2/php.ini.

Once you find the file, you can edit it with text editors such as nano or vi. Remember that after editing, you need to restart the web server or the PHP-FPM service for the changes to take effect. If the service is not restarted, PHP keeps running with the old configuration it loaded into memory.

  1. Connect to the server via SSH and enter the php --ini command.
  2. Use the grep command to filter for the specific configuration file that is loaded.
  3. Open the file for editing with the sudo nano /path/to/php.ini command.

What to Do When You Cannot Find php.ini on Shared Hosting

On shared hosting, the server’s main php.ini file is usually off-limits because it affects every user. In this case, hosting companies allow a “local php.ini” or “.user.ini” so users can set their own limits. If you do not see a php.ini file in the root directory, you can create a new one yourself and add only the lines you want to change. After reading the main configuration, the server reads this local file and gives your settings priority.

On some server configurations (especially Apache), PHP settings can also be managed through the .htaccess file. This method requires the AllowOverride permission to be set on the server. Directives starting with php_value or php_flag that you add to the .htaccess file can override the settings in php.ini. These lines only work when PHP runs as an Apache module (mod_php) or on LiteSpeed; on servers using PHP-FPM / CGI they can cause a 500 error, and .user.ini is used instead.

If neither php.ini nor .user.ini works, you can use WordPress’s wp-config.php file as a last resort. Although this file does not change PHP settings directly, it lets you define the memory limit (WP_MEMORY_LIMIT) allocated to WordPress. Still, the soundest solution is to ask your hosting provider’s support team which method the server supports.

  • Create an empty .user.ini file in your site’s root directory and add your settings there.
  • On Apache servers, try adding php_value directives to the .htaccess file.
  • Add the relevant definitions to the wp-config.php file to increase the WordPress memory limit.

As web technologies have advanced and the PHP 8.x series has become standard, the minimum system resources WordPress sites need have also grown. For a modern WordPress site to run smoothly, a few critical values need to be set in php.ini. These values are vital especially when you use resource-hungry tools such as Elementor, WooCommerce or advanced booking systems.

By today’s standards, the memory limit (memory_limit) should be at least 256MB, ideally 512MB. The upload limit (upload_max_filesize) can be set to 64MB or 128MB for high-quality images and video. It is also recommended to set max_execution_time to 300 seconds (5 minutes) so database operations and API connections do not time out. These settings let your site complete background tasks without interruption.

On the security side, the expose_php = Off setting should be used to hide the server’s PHP version. In addition, adding risky functions such as exec, shell_exec, system under the disable_functions line can stop a potential intrusion from executing commands across the server. These two settings can only be changed in the main php.ini file; they cannot be set with .user.ini or .htaccess.

  1. memory_limit = 512M: Provides enough memory for complex plugins and themes.
  2. upload_max_filesize = 128M: Allows large media files to be uploaded.
  3. max_execution_time = 300: Prevents long-running processes from being cut off.
  4. post_max_size = 128M: Ensures form data and large submissions are transmitted smoothly.
  5. display_errors = Off: Improves security by hiding error messages from visitors.

Source: Official WordPress system requirements

Verifying php.ini Changes in WordPress

After finding and editing the file, you need to check whether your changes have actually taken effect. Users often change the settings, but the old values stay active because of server caching or services that were not restarted. WordPress’s built-in “Site Health” tool is the easiest place to check. In the admin dashboard, go to “Tools > Site Health > Info > Server” to see your current PHP limits.

Another way to verify is to monitor the error logs. If you increased a memory limit and still get errors, either the server did not accept your change or another configuration file (for example, a plugin’s own setting) is overriding the value. In such cases, review the server logs to work out which value PHP is reading from which file.

Finally, if the server uses PHP-FPM, you may need to restart the PHP service manually for the changes to apply. On shared hosting this usually happens automatically, but VPS users must run the systemctl restart php8.x-fpm command. Confirming your changes ensures your site will run stably and prevents technical problems down the line.

  • Check your PHP limits in the WordPress “Site Health” screen.
  • Review the server error logs to track the effect of your changes.
  • If the changes do not show up, restart the PHP service or the web server.

Source: PHP Manual: The configuration file (php.ini)

Frequently Asked Questions

I changed php.ini but the settings did not change. Why?

The server cache or the PHP-FPM service may still be holding the old settings; in that case, restart the service or wait a while. A .htaccess or .user.ini file may also be overriding your settings.

I have no access to php.ini on shared hosting. What can I do?

Create a file named .user.ini in the root directory and add the PHP directives you want. If that does not work either, ask your hosting company’s support team to raise the limits.

What should I set the memory limit to?

256MB is enough for standard blogs, but 512MB is the soundest value for online stores or sites with many plugins. Setting needlessly high values (for example 2GB) does not speed up your site; it just lets a faulty script eat up the server’s memory.

Where is the php.ini file in WordPress?

WordPress does not come with its own php.ini file; the file is on the server, and the “Loaded Configuration File” line in the phpinfo() output shows its full path. If you cannot edit it, use .user.ini in the root directory.

Which php.ini file should I edit for which PHP version?

Edit the file in the directory for the PHP version your site is actively using (for example 8.3 or 8.4). The phpinfo() output clearly shows the active version and the file path.

Result

Finding and optimizing your WordPress php.ini file is one of the most important steps in strengthening your site’s technical foundation. With the methods in this guide, you can take control of your server and run a fast, secure website that meets current standards.

In summary
In this article, we looked in detail at where the php.ini file, which is vital for WordPress sites, is located in different server environments, how to find it and which configuration settings we recommend. We explained step by step how to optimize your server performance using phpinfo(), SSH commands and panel access.