Home » PHP » increase execution time file size memory limit in php.ini

How to increase max execution time, file upload size, memory limit in php.ini file and htaccess file? When you are executing large file you have to seen Fatal error: Maximum execution time of 30 seconds exceeded in…., Fatal Error: Allowed memory size of 8388608 bytes exhausted…. etc.In this post is describing how to solve this error using php.ini file or htaccess file.

increase max_execution_time in php.ini file

Put this code in your file at the top.

ini_set('max_execution_time', 300); //300 seconds = 5 minutes

You can put this in the php.ini file.
max_execution_time = 30 ;

increase max_execution_time using htaccess file



php_value max_execution_time 259200

Increase post_max_size, upload_max_filesize,memory_limit,max_execution_time,max_input_time,session.gc_maxlifetime



php_value post_max_size 5M
php_value upload_max_filesize 5M
php_value memory_limit 300M
php_value max_execution_time 259200
php_value max_input_time 259200
php_value session.gc_maxlifetime 1200

WordPress

If wordpress, set this in the config.php file,


define('WP_MEMORY_LIMIT', '64M');
set_time_limit(0); // at the top

increase execution time in wordpress

Drupal

If drupal, sites/default/settings.php

ini_set('memory_limit', '128M');

Other frameworks

If you are using other frameworks,

ini_set('memory_limit', '128M');

About Sumith Harshan

Sumith Harshan is the Managing Director of the WebXtreams(Pvt) Ltd in Sri lanka.Specializes in Java Script, JQuery, HTML4/5, CSS2/3, PHP, CodeIgniter, CakePHP, J2SE, J2EE, XML, Hacking & Security, Mobile Interface Developing, Magento, WordPress, Joomla, Drupal and PHPBB.

Tags

Similar posts

  • Abraham Padilla

    Very informative blog, I want to know…I have my WP site on a godaddy server, and im trying to create a clone of my site – but the plugin im using is taking long to create the package – this process gets killed by my server. I was told to add php_value max_execution_time 0 to htaccess file.

    for one I dont know where to place this code, however when I did I get
    Internal Server Error. please any help will be appreciated.

    • http://www.webexplorar.com/ Sumith Harshan

      Internal Server Error is happened when you put these script in the htaccess file. You need to put this script in the wordpress config.php file in the root directory.
      define(‘WP_MEMORY_LIMIT’, ’64M’);

      Don’t change the file permission of config.php file.

      -If you can see php.ini file put this script top of that file and save it.
      max_execution_time = 259200 // in seconds

      -If you can see it, you can access it when you are clicked file manager icon, then open a popup window and mark/click “Show hidden files” check box.Then you can see it.

      -If not see access file via http://FTP.Then you can see it.

      -If not success, go to your plugin folder and open it’s index.php file and put these scripts top of the file and save it.
      If you can tell the plugin name I can tell exactly what file you need to put this script.

      ini_set(‘max_execution_time’, 300); //300 seconds = 5 minutes

      Change this 300 seconds for large time(like 5 hours in seconds)

      Simply you can backup your file using cpanel. File backup and database backup.

      If you want to more instructions you can put comments here.

      Thank you !

      • Gidoliny

        jw-player-plugin-for-wordpress works only 5 min; Help, Me Please

        • http://www.webexplorar.com/ Sumith Harshan

          Can you send the url?

          • Gidoliny

            Sumith, Can You help me?

          • Sampath

            Send the site url.I’ll check