PHP.ini is an important WordPress file that you can configure to extend your site’s functionality and improve its performance. Although the file is relatively easy to work with, you might not know how to locate and edit its settings.
Fortunately, this straightforward guide can help you easily locate your PHP.ini file in WordPress. Then, you’ll be able to edit and configure it to maximize your site’s performance.
Let’s take a closer look at PHP.ini and show you where to find it. Then, we’ll discuss three ways to edit it and boost your site’s performance.
What is the PHP.ini file?
In other words, PHP is the scripting language used by WordPress on the server side of operations. Through PHP, WordPress is able to display all of a website’s content, like blog posts, products, and more.
PHP.ini is the default configuration file for PHP on your WordPress site. You can change its default settings and run applications requiring the PHP scripting language. Overall, it’s a pretty important file when it comes to your site’s functionality and performance.
When would editing the PHP.ini file be required?
Although PHP is essential to WordPress, it has pretty limited default configuration settings. Fortunately, thanks to PHP.ini, you can override the default values for the following settings:
- Maximum file size upload. Increasing this limit is ideal if you run a photography website or any other content-heavy site. Since videos and images tend to have large file sizes, editing this setting will enable you to upload heavier clips and photos.
- File timeouts. When a file takes too long to process, your website will return an error message and stop processing the request. You can increase the number of seconds allowed before your upload times out.
- Resource limits. You can increase the memory available to upload files and run commands. Plus, if you write long blog posts or add plenty of images to your site, you might increase the maximum post size to accommodate more data.
- Maximum execution time. This setting determines the number of seconds a script is allowed to run before it gets terminated by the parser. As such, it helps prevent poorly-written scripts from draining your server.
Essentially, by editing these PHP configurations, you’re able to extend your site’s functionality and improve performance. Additionally, you might also want to edit PHP.ini in WordPress to enable or disable file extensions.
For example, a common error that you may see is “Your PHP is missing the MySQL extension.” In this instance, editing the PHP.ini file can enable the extension and clear the error message.
Can all WordPress site owners edit their PHP.ini files?
This depends on your server environment and system. Typically, it’s up to your WordPress hosting provider to allow access to the file. If PHP.ini is inaccessible, you may need to contact your host for support and see if they’ll help you edit it.
Certain hosting types are less likely to give users access to the PHP.ini file. For instance, a shared hosting setup consists of multiple websites hosted on a single server. It’s a great way to reduce costs, but you won’t have root access to your server.
By contrast, you’re more likely to have access to your PHP.ini file if you’ve signed up for a Virtual Private Server (VPS), dedicated server, or reseller hosting plan. In these setups, you’re not sharing resources with other sites, so you have more freedom to configure your website’s server.
Fortunately, if you don’t have direct access to the PHP.ini file in WordPress, there are some useful workarounds that can achieve the same results. Let’s take a quick look at two of them:
1. Edit your .htaccess file
Editing PHP.ini can increase your site’s maximum execution time. But if you don’t have access to the file, you can also adjust this setting in .htaccess.
First, you must access your website files via FTP or File Manager. Then, find the root directory of your site. This is usually labeled public_html.
Open the .htaccess file and paste the following code into the editor:
php_value max_execution_time = X
Replace the “X” with an amount of time in seconds. Inserting “60” will increase the maximum execution time to one minute, giving your website more time to load scripts before terminating the process.
2. Edit your wp-config.php file
Additionally, you may want to eliminate the run time limit in WordPress. This setting controls the time your site will spend on an operation before timing out. At that point, your site will return an error.
To extend the time limit, locate your wp-config.php file and paste the following code into the editor:
set_time_limit = 60
If the code is already there from work you’ve done previously, simply change the value to 60. You can exceed 60 seconds, but doing so may be risky since the setting is in place to protect your system from poorly-written scripts.
Where is the PHP.ini file located?
By now, you should have a basic idea of the purpose of the PHP.ini file. Now you might be wondering: where is PHP.ini in WordPress?
If you have a PHP.ini file, you’ll usually find it in the root directory of your WordPress site. If not, you can create a new file for your website, which we’ll show you how to do in the next part of this article.
There are also different locations if you’re working in a local environment. If you’re a WAMP user, you can locate your WordPress PHP.ini file by right-clicking on the program icon. Then, head to PHP → php.ini.
In XAMPP, all you need to do is open the program and click on Config. Then, find the php.ini option within the menu.
Finally, using Linux, you can typically locate your PHP.ini file in the Loaded Configuration File. To access this, you’ll need to enter the following code below the terminal:
PHP –I | grep “Loaded Configuration File”
You should receive the following output:
Loaded Configuration File => /usr/local/lib/php.ini
If you still can’t find your PHP.ini file’s location in WordPress, it’s time to contact your web host or create your own file. Let’s look at how this process works.
What to do before editing your PHP.ini file
Before making any changes to your site files, including PHP.ini, it’s a good idea to make a fresh backup of your site. That way, if you make any mistakes, you’ll be able to revert your site to an earlier version in just seconds.
If you don’t already have a WordPress backup plugin, consider installing Jetpack VaultPress Backup.
Not only does VaultPress back up your entire website, but it also stores copies of your database, your site files, and all WooCommerce customer and order data.
How to open and edit your WordPress PHP.ini file
There are several reasons you may want to edit your PHP.ini file. Here are some of the recommended configurations that might be useful:
max_execution_time = 180 memory_limit = 128M post_max_size = 64M upload_max_filesize = 64M max_input_time = 60 file_uploads = On safe_mode = Off
Adjusting the maximum execution time will increase the time available to execute every script on your site. Essentially, this refers to the time the server needs to run the commands, so it can be handy if you have heavy scripts.
The memory limit enables you to restrict and expand the memory usage of PHP. Generally, this concerns the memory needed to upload files and run commands on your site.
Post max size defines the maximum data a post can have. So, if you have plenty of images on your pages or write super long blog posts, you might want to increase this value.
Additionally, you can increase the upload max file size. This is a helpful setting for photographers or other creatives who need to upload heavy media files like videos.
However, before you can make these edits, you’ll need to locate an existing PHP.ini file or create a new one. Keep in mind that if you’re using shared hosting, you may be unable to follow these steps.
1. Use an FTP client
Using an FTP client is one of the easiest ways to find and access your PHP.ini WordPress file. Once you’ve got a current backup in place, it’s time to connect to your site via FTP.
If you don’t already have one installed, you’ll need to find an FTP client like FileZilla and download it to your computer.
Then, you can connect to your site via FTP to access your site’s files. Just enter your FTP credentials to establish a connection (which you can typically get from your hosting provider).
Once the connection is made, locate the root directory of your site. This is usually labeled public_html or public.
If you have a PHP.ini file, you should see it in this folder. If you can’t find it, you can locate it manually by creating a new PHP file and pasting the following code into it:
<?PHP phpinfo(); ?>
Update the file by saving your changes. At this point, open the file in your browser to identify the correct file path.
Simply type your website’s URL followed by the file name you chose into the search bar. This might look something like this: yourwebsite.com/file-name.php.
This should launch a page in your browser with information about your PHP installation, including the file path for your PHP.ini file. You can find this information within the Configuration File Path or Loaded Configuration File field.
Once you’ve opened the php.ini file, enter your custom directives. You can check out this list of common PHP.ini directives and syntax rules to configure the file correctly.
Finally, save your file! The settings should start taking effect within a few minutes.
2. Use cPanel
cPanel is a common control panel tool included in many hosting provider dashboards. It’s pretty straightforward and easy to use.
First, you’ll need to log in to your hosting account and locate the cPanel File Manager. Then, open your public_html folder.
Here, you’ll want to look for your PHP.ini file by its name. Note that it might also be hidden, so click on Settings and check the box next to Show Hidden Files (dotfiles).
If you still can’t find it, click on New file and name it “php.ini”. Make your edits, save the file, and your site should start showing the changes within a few minutes.
Depending on your hosting account dashboard, you may also have access to the MultiPHP INI Editor. This tool enables you to configure your PHP settings from a list of available directives. Keep in mind that the editor is typically only available with VPS, dedicated server, or reseller hosting plans.
3. Utilize a WordPress file manager plugin
File manager plugins enable you to easily edit your website’s files without playing around on the back end. Therefore, using a plugin is an accessible, quick, and beginner-friendly way to access your WordPress PHP.ini file.
With a file manager plugin, you’ll typically get access to a clean, intuitive interface to manage, upload, download, and even back up and restore files. One of the most popular options is Advanced File Manager.
To edit your PHP.ini file with Advanced File Manager, you’ll need to install the plugin in WordPress. In your dashboard, navigate to Plugins → Add New. Then, search for “Advanced File Manager” and click on Install Now → Activate.
Once the tool has been installed successfully, head to File Manager → File Manager to access the plugin’s interface.
You may be able to find PHP.ini within the file list. Otherwise, click on New file and select txt to create a simple text file. You’ll be prompted to name the file, so call it “php.ini”.
Next, select the newly created file and click on Edit file. Then, input your code, along with any custom configurations.
Again, make sure to save your changes when you’re done to finish setting up your WordPress PHP.ini file.
Frequently asked questions about the PHP.ini file
We’ve just covered the basics of finding and editing your PHP.ini file in WordPress. If you still have any questions, we’ll answer them in this section!
What if I don’t have access to the PHP.ini file? Can I still edit my PHP settings?
If you can’t access your PHP.ini file, you may be able to edit your PHP settings by creating a new PHP.ini file via FTP, File Manager, or a file manager plugin. Keep in mind that this typically isn’t available for shared hosting plans. Alternatively, you can configure some PHP settings using .htaccess and wp-config.php.
Can I create a new PHP.ini file to overwrite my hosting provider’s file?
In some cases, it’s possible to override PHP settings by creating a new PHP.ini file. If this doesn’t work, you’ll need to contact your hosting provider directly. You may need to switch to a different hosting configuration, like VPS or dedicated hosting.
Do PHP.ini changes take effect immediately?
PHP.ini changes often take effect immediately or within a few minutes. If you’ve made edits, but your site’s configuration hasn’t changed, you may be editing the file in the wrong directory.
Can your WordPress site’s PHP.ini file be hacked?
Although it’s not very common, your WordPress website can be hacked via its PHP.ini file. That’s why it’s worth investing in a high-quality hosting provider with strict security protocols, along with WordPress security plugins.
Locate and edit your PHP.ini file
Editing the PHP.ini file is a great way to extend the functionality of your site and configure its PHP settings. But you might not know how to carry out these changes.
To recap, here are three ways to locate and edit PHP.ini:
- Use an FTP client.
- Use cPanel within your hosting account dashboard.
- Utilize a file manager plugin like Advanced File Manager.
Before you start editing any of your site files, it’s important to back up your site. Jetpack VaultPress Backup backs up all your database tables, website files, and WooCommerce data, so you’ll never lose your content. Better yet, it’s super simple to restore your site if anything goes wrong.
Explore the benefits of Jetpack
Learn how Jetpack can help you protect, speed up, and grow your WordPress site.
Get up to 50% off your first year.Compare plans