46

I want to increase max execution time on my wordpress site. I know I should edit php.ini, but can't seem to find it!

any tips?

4
  • Is there a phpinfo link anywhere? That would give the location of php.ini
    – pavium
    May 29, 2011 at 2:19
  • @pavium there's an answer here on finding your php.ini file wpza.net/wordpress-setup/…
    – WPZA
    Dec 22, 2018 at 0:26
  • On docker wordpress you can find it at /usr/local/etc/php/. If you don't see it, create one Feb 21, 2020 at 17:13
  • Create a PHP file, put <?php echo php_ini_loaded_file(); in it - go to file in browser, if some php.ini is loaded, the path will be there :-) PHP docs
    – jave.web
    Jun 14 at 20:54

17 Answers 17

33

I see this question so much! everywhere I look lacks the real answer.

The php.ini should be in the wp-admin directory, if it isn't just create it and then define whats needed, by default it should contain.

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
7
  • 2
    If I add it to wp-admin, will this get lost on update? Aug 2, 2016 at 14:27
  • 2
    @JomarSevillejo no its does'nt Oct 6, 2016 at 13:41
  • 2
    But if the php.ini file is not under wp-admin folder in the first place, how will WP know to use it only by creating it there?? I mean, the web server knows where the php.ini file is when it runs, so what makes it change its reference after I manually create it somewhere else??
    – TheCuBeMan
    May 5, 2017 at 7:09
  • 1
    Thank Brad. This helped solve my problem. I had this issue where I couldn't edit my shop page. I checked the wp-admin directory and I coudn't find a php.ini file. So I guess Wordpress does not provide it initially. I am not sure. So I followed your instructions and it worked.
    – AllJs
    Dec 2, 2017 at 23:50
  • 2
    The question is "How can I find php.ini" file and then you write "the php.ini should be in wp-admin directory" but where is that directory....???
    – Yuval Levy
    Sep 24, 2018 at 19:16
14

Wordpress dont have a php.ini file. It just a cms, look into your server. for example if you use XAMPP in windows xampp\php\php.ini is the location.

1
  • If I am using xampp and I create a php.ini in wp-admin, then will the wp-admin file override the xampp defaults?
    – nu everest
    Dec 11, 2016 at 15:58
14

Okay. Answer for self hosted wordpress installations - you'll have to find the file yourself. For my WordPres site I use nginx with php7.3-fpm.

Running php -i | grep ini from console gives me several lines including: Loaded Configuration File => /etc/php/7.3/cli/php.ini. This is ini configuration when running php command from command line, a.k.a. cli.

Then looking around I see there is also a file: /etc/php/7.3/fpm/php.ini I use FPM service so that is it! I edit it and THEN reload the service to apply my changes using: service php7.3-fpm reload.

That was it. Now I can upload bigger files to my WordPress. Good luck

3
  • 1
    This needs to be documented somewhere. Thank you kind stranger! Sep 2, 2021 at 16:26
  • You are a savior! Sep 8, 2021 at 10:15
  • 1
    on my apache2 it was at the same location but /etc/php/7.4/apache2/php.ini Nov 9, 2022 at 2:08
12

I used this, very cool tool

https://wordpress.org/plugins/php-settings/

This plugin provides a simple user interface with a code editor to edit your local .ini settings.

This can be used to change settings like upload_max_filesize or max_execution_time which are often set to very low values by the hosting companies.

5
  • The library is not available anymore :(
    – Struki84
    Oct 28, 2019 at 18:42
  • This plugin has been closed as of February 15, 2019 and is not available for download. Reason: Guideline Violation. Dec 8, 2019 at 9:33
  • 3
    Here is my plugin which basically does the same thing and more than the above: wordpress.org/plugins/custom-php-settings Mar 5, 2020 at 14:35
  • "This plugin has been closed as of February 15, 2019 and is not available for download. Reason: Guideline Violation."
    – jord8on
    Dec 20, 2020 at 0:20
  • Well well, it would be preferable to learn how to script and code rather than always "use this plugin" .... ? just my 2 cents
    – avia
    Jul 9, 2021 at 6:51
10

Open .htaccess file in a code editor like sublime text and then add..

php_value upload_max_filesize 1000M
php_value post_max_size 2000M
php_value memory_limit 3000M
php_value max_execution_time 1800
php_value max_input_time 180

hope it helps..............it did for me.

2
  • where is htaccess?
    – Mike Yang
    Nov 23, 2018 at 10:58
  • This worked for me. .htaccess is located in /var/www/html.
    – stidmatt
    Sep 3, 2021 at 5:32
7

Use the php_ini_loaded_file function to get the location of your php.ini file.

<?php
$inipath = php_ini_loaded_file();

if ($inipath) {
    echo 'Loaded php.ini: ' . $inipath;
} else {
    echo 'A php.ini file is not loaded';
}
4
  • thanks that was useful.. But, I got this message: "Loaded php.ini: C:\php5\php.ini".. what does that mean? it's on my c drive?
    – Maha
    May 30, 2011 at 14:29
  • Well no need to mess up with php.ini, Use this function php.net/manual/en/function.set-time-limit.php May 31, 2011 at 6:33
  • This helped me locate the php.ini file. It's basically the file that is created when php is installed on the server. Thank God for this answer I located it on my web host and it was inside some cryptic location that I didn't have access to!
    – Mugen
    Dec 31, 2019 at 14:53
  • That was extrtemely useful to debug my situation
    – avia
    Jul 9, 2021 at 7:00
5

A php.ini file is not installed by default with Wordpress. You may have one already installed by your web host. Look in your root directory or ask your web host or read your web host's documentation on how to install one.

Look for max_execution_time in your php.ini file and change to 60 or 90

1
  • alright then what's the easiest way to increase max execution time for wordpress sites?
    – Maha
    May 30, 2011 at 14:25
5

If you have access to our webroot, create a file asdf.php with

<?php phpinfo(); ?>

in it and point your webbrowser to it. You should see all info in the first section.

  • Configuration File (php.ini) Path
  • Loaded Configuration File
  • Scan this dir for additional .ini files
  • Additional .ini files parsed

This works for any php application and is therefore the universal way to find our php.ini

4

This Worked For Me. I have installed wordpress in godaddy shared server. Open .htaccess file using editor and add the following from the first line,

#  BEGIN Increases Max Upload Size
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 300
php_value max_input_time 300
#  END Increases Max Upload Size

This solved the php.ini issues for me in the server.

3

I just came across this thread while searching for an answer to why the php.ini file would be within the /wp-admin/ folder for WordPress that I have just seen in an odd setup - because it really really shouldn't be there.

WordPress by default doesn't include a php.ini file within the /wp-admin/ folder, so you should not have one there yourself. The php.ini file is designed to override the main server PHP configuration settings so that your account on the server is treated differently, within limits. As such, if you do need to use this file, please, for your own sanity (and that of others who happen to work with your systems in the future...), place the php.ini file in the root of your account, not hidden away in the /wp-admin/ folder, or any other folder for that matter.

I'm surprised to see so many others commenting that it should be in the /wp-admin/ folder to be honest. I'd love to see some official documentation from WordPress stating that this is best practice, as this is certainly something that I would completely avoid.

1
  • This is the most sensible answer on this page. I found my php.ini file eventually. And it wasn't located in the wp-admin directory. Wordpress doesn't really provide that file. This is a file created by installation of php. Hence, it resides on the host server that you're hosting on.
    – Mugen
    Dec 31, 2019 at 14:50
1

Create a file yourself php.ini anywhere in your root or wp-admin folder and add the necessary code to the file it should work

0

If your hosting provider is using Plesk, go to Websites & Domains > PHP settings from where you can seamlessly change memory_limit, max_execution_time, max_input_time, etc. Hope it helps.

0

If you use cPanel and have installed CloudLinux you can go to section Software > Select PHP Version > Switch To PHP Options and define max_execution_time among other options.

Short gif: http://cloud.mercadoalvo.com/nDdE

0

you can do it from the Cpanel: 1.- CPANEL 2.- Select PHP Version 3.- Swich to PHP options 4.- Edit:

max_execution_time 1800 max_input_time 64 max_input_vars 6000 memory_limit 512M post_max_size 128M upload_max_filesize 128M

0

The name of the custom ini file depends on the user_ini.filename php setting. By default this should be .user.ini and the custom configuration files are used on a per-directory basis, so you should be able to either put it in the root of your Wordpress installation or under the wp-admin folder.

You can check the name of your custom configuration file by running:

php -i | grep user_ini.filename

I have created a plugin which makes it possible to change php settings from the Wordpress administration:

Custom PHP Settings

The plugin makes it possible to change settings either using the .htaccess file or the custom php.ini file, depending on how php is running.

0

I am adding an answer based on my experience and also thanks to Michael Cropper and Salman von Abbas for their inputs.

The php.ini file is created when php is installed on the server. I believe that wordpress installation requires php to be installed on the server. So your webhost typically installs it on their server and then sells you the hosting space. Then you install your wordpress on it.

Hence, it follows clearly from this that the php.ini file will not be present in the wp-admin folder.

So you need to look for it either at your root folder (but most likely it won't be there if you're on a shared webhosting plan). Then you need to create a file as such:

create a new file in the location = /public_html/your_domain/any_name.php

Put the following code inside the file:

<?php
$inipath = php_ini_loaded_file();

if ($inipath) {
    echo 'Loaded php.ini: ' . $inipath;
} else {
    echo 'A php.ini file is not loaded';
}

Now try to access the file through your browser as follows:

https://your_domain/any_name.php

This should show a message that clearly states the location of your php.ini file.

If you're on a shared hosting plan then you probably won't have access to this folder. You will need to inform the web hosting support to take care of this for you.

Hope this helps!

0

use this in your htaccess in your server

php_value upload_max_filesize 1000M php_value post_max_size 2000M

Not the answer you're looking for? Browse other questions tagged or ask your own question.