Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 20-05-2009
Member
 
Join Date: Feb 2009
Posts: 32
How to increase memory limit in php

hello friends,

I want to increase my memory limit in order to make my website run faster. I know it's possible with the php code, many webmaster do it . But I am completely unaware of this ? can anybody help me with how can I increase the memory limit using php ?

plz help....
Reply With Quote
  #2  
Old 20-05-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: How to increase memory limit in php

The default memory is set for 8M

Warning- Before doing anything, always make a backup file of php.ini .
Note - If you don't know where your php.ini file is located, the phpinfo.php file will show you where the pnp.ini file is at.

Open your php.ini file. If your server is a Webune Dedicated Server with Redhat, Centos or Fedora, you can run the following command to edit the php.ini file:
Code:
nano /etc/php.ini
Find
Code:
memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)
and replace with
Code:
memory_limit = 16M ; Maximum amount of memory a script may consume (8MB)
Save the file - press Ctrl+x. You will be asked to save changes, type the letter "y" for yes

Hit Return at the next prompt.

Restart Apache Server with the following command
Code:
/etc/init.d/httpd restart
Here, your phpinfo.php file should show 16M instead of 8M
Reply With Quote
  #3  
Old 20-05-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: How to increase memory limit in php

If you are using drupal and wish to increase php memory limit -
  1. Locate the php.ini file used by your web server. (Tip - use the phpinfo() PHP function to find it). During installation Drupal checks the PHP Memory Limit and if it's less than 16M an error message also provides the path to the php.ini file.

  2. Edit the memory_limit parameter in the php.ini file (usually in a section called Resource Limits)
    memory_limit = 16M ; Maximum amount of memory a script may consume (16MB)
    If there is no section already for this, place the above line at the end of the file.

  3. Restart Apache.
Reply With Quote
  #4  
Old 20-05-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: How to increase memory limit in php

Changing Memory Limit

There are 3 ways -

1. Changing memory_limit globally from php.ini

This is the simplest method. In this, you just need to edit your php.ini and change the memory_limit to whatever you need. For eg:
memory_limit = 32M

To do this, you will need access to make changes to php.ini on the system. Since this change is global, it will be used by all php scripts running on the system. Once you change this value, you will need to restart the web server in order for it to become active.

2. Changing memory_limit using .htaccess for a single folder/vhost

If you want to change the memory limit only inside one folder (normally one application or virtual host) that needs this value changed for its functionality, you have to add to the respective location .htaccess something like:
php_value memory_limit 64M

This change will be local only, and can be useful for webmasters that don’t have control on the system php.ini. This change would not require a reload and will become active immediately.

3. Changing memory_limit inside a single php script.

You can even set the memory limit to the directive inside a single php script. To do so,
ini_set('memory_limit', '64M');

The advantage of this method is that you have more control and set this value just where you know it is really needed. Also it can be done without having access to the system php.ini, and will become active immediately.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to increase memory limit in php"
Thread Thread Starter Forum Replies Last Post
How to increase Creative X-Fi 8000 song limit Visitator Hardware Peripherals 5 24-04-2011 10:18 AM
Increase RAR attachment Limit avvia Windows Software 3 06-07-2009 11:53 AM
Increase limit of downloads of Internet Explorer 7 in Windows Vista Valerian Tips & Tweaks 3 22-02-2009 09:38 PM
Increase the PATH environment variable limit to 2048 char on 2003 Morten Ross Windows Server Help 5 21-05-2008 01:01 AM
Increase database size limit to 75GB in Exchange Landon Small Business Server 1 30-03-2007 09:40 AM


All times are GMT +5.5. The time now is 12:09 PM.