PHP’s memory_limit prevents scripts from overloading server resources, but modern websites like WordPress or Joomla often need more memory to avoid errors like “Allowed memory size exhausted.” This guide simplifies checking and increasing the PHP memory limit using AvaHost’s cPanel or other hosting setups, with practical examples and troubleshooting tips.
PHP is the programming language behind most modern websites. It has a memory usage limit — memory_limit — which controls how much server memory a single script can use.
If your site slows down or shows an error like:
it means the current memory limit is too low and needs to be increased.
phpinfo();
This file stores PHP configuration settings. It’s available on VPS or dedicated servers, or if your hosting provider allows custom PHP configuration.
Steps:
memory_limit = 512M
If you’re on shared hosting with Apache, look for a file called .htaccess in your site’s root folder. Add this line:
If this causes a 500 error, your server may be running in CGI mode. In that case, remove the line and try another method.
If you’re running WordPress:
define('WP_MEMORY_LIMIT', '256M');
Increasing the PHP memory limit is a simple fix for “memory exhausted” errors, ensuring your WordPress, Joomla, or custom site runs smoothly. With AvaHost’s cPanel tools, you can apply the methods above—php.ini
, .htaccess
, or wp-config.php
—and test changes easily. These steps and examples empower you to optimize performance without technical expertise, keeping your site stable and efficient.