How to change the memory_limit in .htaccess file

January 22, 2011 / cPanel & WHM

Users can make alterations in the memory_limit using the php.ini file located at /etc/php.ini. In case you have a shared server, it is not recommended to make these changes on your own. The main reason is that, if you make changes to memory_limit on a shared server using a php.ini file, every account on the server would reflect these changes. Though, this is the case with Windows servers.

Alternately, you can copy the php.ini file into the individual Linux user account and search for the memory_limit in the file using a suitable editor on the server and make amendments to the values.

There is also one more method to go about doing this, i.e., with the .htaccess file. Users can simply create a .htaccess file and add a code in that file.

Here is the procedure to do that:

  1. Build a .htaccess file using.
    pico .htaccess
  2. If you wish to set a memory_limit of 64 MB, you must use the following code within the .htaccess file:
    php_value memory_limit 64M
  3. Press ctrl + c for saving and exiting the file.
  4. You must then create a phpinfo.php file using the following :
    pico phpinfo.php
  5. Now use the following code within the file.
    <?
    
    phpinfo();
    
    ?>
  6. Now look for the file in the browser and for the memory_limit and confirm if the changes have been applied.

In case you wish to do it using FTP, then the following steps can be followed:

  1. Make an htaccess.txt file on your local system.
  2. Add the code for changing the memory_limit to the file.
    php_value memory_limit 64M
  3. Then upload the htaccess.txt file using an FTP client software that you usually use.
  4. Upon uploading the onto the server using FTP account, you must rename it to .htaccess using the FTP client software.
  5. Create phpinfo.php file over your local machine.
  6. Type the following code within the phpinfo.php file.
    <?
    
    phpinfo();
    
    ?>
  7. Again, using an FTP client, upload it onto your server.
  8. Now look for the file in the browser and for the memory_limit and confirm if the changes have been applied.

NOTE: These steps can only be used by customers who have a VPS or a higher web hosting account. Customers using a shared server, specifically Linux Shared Hosting, must contact the Linux support department for increasing the php memory_limit.

Like this post ?

Share on your Social Networking Profile ( Facebook, Twitter & Google+ ) and get a flat 10% Recurring discount on our VPS Hosting and Dedicated Servers.

Email us the shared link at: [email protected] or speak to our live chat operator now, by clicking on the “Live Chat” scroller on the left-hand side of this page, and we will provide you with the discount coupon right away!

Spread the love