WordPress / Website PHP Memory Limit & Time Limits

WordPress LogoThis post is a little off topic for Law enforcement Applications, but I am currently developing several applications which utilize a LAMP (Linux, Apache, MySQL, PHP) stack IE. a web server. The applications I am working on are unpublished at this point but as a hint, can manage emergency operations including natural disasters, SWAT / Hostage Situations, and much more. While developing this, it was determined I had the need to increase the memory usage of PHP and script execution time limit to accommodate several functions of the application. As an example, lopping through mail lists sending out alerts. Simply put, I had to locate the PHP initialization file (php.ini) for short, or even create it, to set my new memory limits needed for my applications to run without problems for Fatal Errors. This can be extremely usefully if you are getting errors on your web server, or even a shared hosting platform, with what ever program you are running via PHP, even WordPress, that needs a higher memory or time limit.

NOTE: Know that each hosting service is different, and the methods mentioned below may or may not work for you. Before trying these methods to increase your system status limits, it’s always best to contact your respective hosts first and ask them if they can make these adjustments for you.

The two issues you are dealing with are WP Memory Limit and PHP Time Limit.

WP / PHP Memory Limit (WordPress)

The WP Memory Limit is the maximum amount of memory (RAM) that your site can use at one time. When you reach your Memory Limit, you’ll encounter a fatal error. Several things consume memory, such as WordPress itself, the theme you’re using, and the plugins installed on your site, or individual scripts, loops, or functions. Basically, the more content and features you add to your site or application, the bigger your memory limit has to be.

Change your PHP Memory Limit in php.ini File

  1. PHP INI FileLocate your php.ini file. If you can’t find it, then you can create your own php.ini file in the root folder of your WordPress installation.
  2. If you find your existing php.ini, open the file and locate the following line of code (xx represents a number): memory_limit = xxM. Then change xxM to your desired limit. For example, 256M (This is a good high range).
  3. If you created your own php.ini file, then add the same code inside it: memory_limit = 256M. Simply change the value to the recommended value. For example, 256M.
  4. Save your changes, and reboot your local host or server.
  1. Change your WordPress Memory Limit in WP-config.php File

  1. Locate your wp-config.php file in the root folder of your WordPress installation.
  2. Open the wp-config.php with a text editor program (Notepad, Notepadd++ or TextEdit) and add the following line of code after ‘define(‘WP_DEBUG’, false);: define (‘WP_MEMORY_LIMIT’, ‘256M’);. Simply change the value to the recommended value. For example, 256M.

Change Your PHP Memory Limit in .HTACCESS File

  1. Locate your .htaccess file which is usually in the root folder of your WordPress installation. If you can’t find it, it may be because it’s hidden.
  2. Open the .htaccess file with a text editor program (Notepad, Notepad++, or TextEdit) and add the following line of code: php_value memory_limit 256M. Simply change the value to the recommended value. For example, 256M.
  3. Save the file and refresh your website.

PHP Time Limit

The PHP Time Limit is the amount of time (in seconds) that your site will spend on a single operation before timing out. This is also to avoid server lockups. The default value for the PHP Time Limit is 40 seconds. When an operation reaches the time limit set, then it will return a fatal error that looks like this Fatal error: Maximum execution time of xx seconds exceeded....

Change Your PHP Time Limit in php.ini File

  1. PHP INI FileLocate your php.ini file. If you can’t find it, then you can create your own php.ini file in the root folder of your WordPress installation.
  2. If you find your existing php.ini, open the file and locate the following line of code (xx represents a number): max_execution_time = xx. Then change xx to your desired limit. For example, 300.
  3. If you created your own php.ini file, then add the same code inside it: max_execution_time = 300. Simply change the value to the recommended value. For example, 300.
  4. Save your changes, and reboot your local host or your server.

Change Your PHP Time Limit in WP-Config.php File

  1. Locate your wp-config.php file in the root folder of your WordPress installation.
  2. Open the wp-config.php with a text editor program (Notepad, notepad++, or TextEdit) and add the following line of code after ‘define(‘WP_DEBUG’, false). set_time_limit(300);. Simply change the value to the recommended value. For example, 300.

Change Your PHP Time Limit in .HTACCESS File

  1. Locate your .htaccess file which is usually in the root folder of your WordPress installation.
  2. Open the .htaccess file with a text editor program (Notepad, Notepad++, or TextEdit) and add the following line of code: php_value max_execution_time 300. Then just put in the recommended value. For example, 300.
  3. Save the file and refresh your website.
Share:

Leave a Reply

Your email address will not be published. Required fields are marked *