Introduction
Encountering a PHP memory limit error on your hosting account with DomainIndia.com can be a roadblock, especially when you're running resource-intensive applications or scripts. This article offers a step-by-step guide to seamlessly increasing the PHP memory limit on your account, allowing your scripts to run smoothly.
What Triggers the Error?
If you face an error message like the one below, you've hit the PHP memory ceiling:
PHP Fatal error: Allowed memory size of x bytes exhausted (tried to allocate x bytes)
This essentially means that the PHP script you're trying to execute is demanding more memory than what's currently allocated by the server's PHP configuration.
Solution: Increasing PHP Memory Limit
Before you start, note that while you can increase the "memory_limit" PHP variable for your account, our server's global settings will not be changed. Below are the steps you can follow to update the PHP memory limit:
Method 1: Using .htaccess File
-
Access File Manager: Log in to your cPanel or connect to your account via FTP.
-
Navigate to Directory: Go to the folder where your PHP script resides.
-
Find .htaccess: Look for the
.htaccess
file. Create one if it doesn't exist. -
Edit .htaccess: Open the
.htaccess
file and insert the following line:
php_value memory_limit xM
-
Replace
x
with the desired limit in megabytes (MB), like 128M for 128 MB. -
Save and Close: Save your changes and close the
.htaccess
file.
Caution: Setting the memory limit too high can adversely affect server performance. Always use a reasonable value.
Method 2: Using php.ini File (For Advanced Users)
-
Access File Manager: Log in to your cPanel or connect to your account via FTP.
-
Navigate to Directory: Go to the folder where your PHP script resides.
-
Find or Create php.ini: Look for the
php.ini
file or create one. -
Edit php.ini: Open the
php.ini
file and add or modify the following line:
memory_limit = xM
-
Save and Close: Save your changes and exit.
Note: The changes will take effect after you restart the web server or wait for the server to reload its configuration automatically.
Need Further Assistance?
If you're still facing issues or require more specialized help, please refer to our comprehensive knowledge base or submit a ticket for support.