How to Increase PHP Memory and the Maximum Upload Limit
Dealing with Fatal Errors in WordPress happens to everyone eventually. If you have a multimedia-rich site, then the standard configuration for WordPress will not meet your needs and at some point, you will experience one of the following errors: “Fatal error: The allowed memory size of xxxxxx bytes exhausted” and “filename.jpg exceeds the maximum upload size for this site.”
There are some solutions given for the Fatal Error. Try to follow the steps and hope that you can solve your problem.
1. Edit your wp-config.php file:
wp-config.php is one of the most important WordPress files because it contains your base configuration details. You’ll find it in the root of your WordPress file directory. To edit the memory limit and upload limit, look for this line:
Modify the second parameter by increasing it. As a PHP memory limit of 128M should be more than enough.
Save the file and you’re done. You may need to increase it again if you’re still getting the fatal error, but don’t go overboard or you may crash your server.
If you’re still having the memory limit fatal error in the admin area of WordPress, then you’ll need to modify a different line in your wp-config.php file. To increase the WP memory limit for the administration area look for this line and increase it:
define( ‘WP_MAX_MEMORY_LIMIT’, ‘256M’ );
Admin tasks require more memory, so you’ll need to set it much higher. Double the number you set for WP_Memory_Limit.
2. Edit your php.ini file:
In the event that modifying your wp-config.php file doesn’t address the problem, you’ll have to address the issue within your server settings instead of within WordPress.
If you’re using shared hosting, you will not be able to access your php.ini file, so see the next option instead. If you do have access to php.ini, you’ll most likely find it in the root folder, but the location of the file will vary by host.
To increase the PHP memory limit and upload limit, change these lines in php.ini
memory_limit = 256M
upload_max_filesize = 12M
post_max_size = 13M
file_uploads = On
max_execution_time = 180
Changing the value of max_execution_time will limit the amount of time for a PHP script to run. If the PHP script exceeds the set value (seconds), it will stop the script and report an error.
In many cases, the values you enter should get larger as you go down the list from lines one to three. The upload_max_filesize should be the smallest while the memory_limit should be the largest. The median should be post_max_size. Before checking to see if the error is gone, make sure to clear your browser’s cache.
3. Edit your .htaccess file:
If you don’t have access to php.ini, then your last resort is to modify your .htaccess file. Your .htaccess file starts with a dot because it is a hidden file. If you don’t see it in your root folder, check to make sure that your file manager isn’t keeping those files hidden from view.
To increase the PHP memory, you’ll add the following to your .htaccess file:
php_value memory_limit 256M
php_value upload_max_filesize 12M
php_value post_max_size 13M
If the PHP value memory limit has already been set, then increase it.