Domain Name Registration - Web Development - Web site Hosting - Managed Web site Solutions - Internet Marketing
Register or transfer your Domain Name Today www.  .     

Tutorial - Changing memory limit for PHP using php.ini

You can modify the PHP memory limit allocated to your website application using the php.ini file.

By default, PHP has a memory limit of 16MB. You can change this limit using two files - .htaccess and php.ini. and it's a fairly simple 2 step process explained in the following Tutorial.

Changing memory limit for PHP using php.ini Step 1

First, create a .htaccess file in the folder holding the upload script that requieres more php memory. The .htaccess file located in this folder will tell the webserver to use a custom php.ini file for your PHP application. The file should contain the following line of code:

suPHP_ConfigPath /home/username/folder/

Where "username" is your CPanel username and "folder" is the folder where you will upload your custom php.ini file to.

For example, if you have a folder called "THISONE" in your public_html/ where you will house your upload script, then the path above will look like:

suPHP_ConfigPath /home/username/public_html/THISONE/

Note that this line of code is all that should be present in your .htaccess file. Be aware - the dot before the filename makes it a "hidden" file, i.e. you won't see it once it's uploaded to the server. Be sure to place it into the correct folder in your website file structure.

Changing memory limit for PHP using php.ini Step 2

Next you need to create a php.ini file to tell the server how to behave when you're uploading a file. In this instance we're changing the memory limit, so the directive to specify is:

memory_limit

As with all variables in php.ini, you simply provide the value which you would like it to have.

For example, if you want the limit to be 50MB, it will look like this:

memory_limit = 50M ;

Save the file with these values (there may be other variables here as well e.g. safe_mode and register_globals, upload_max_filesize, post_max_size), and upload it to the folder which houses the script requiring more memory and test.

Note, you can modify a lot of settings using php.ini. The options we list in the Tutorial section are simply the most popular ones, but there are lots more that are available. If you'd like to learn more about how to control php.ini file, please visit http://www.php.net/

Nete-Quette Domains
Nete-Quette.com.au