0
was successfully added to your cart.

How to Setup Your Own Custom php.ini, with Example, Changing Memory Limit for PHP Using php.ini

Hosting is provided on a shared server with a default php.ini.  The default php.ini is hidden so that the server will always have a base version of php.
You can over-ride the php.ini by uploading your own and refering to it via the .htaccess file.

If you use a custom php.ini then any settings from the default will be lost, if you setup your own you must put in all the settings that you need.  You can check PHP settings and modules, see How to Check My PHP Configuration and Version

 

How to Setup Your Own Custom php.ini, with Example, Changing Memory Limit for PHP Using php.ini

You can modify the PHP memory limit for 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.  It’s a fairly simple 2 step process.

  1. Create a .htaccess file in the root directory of the website (folder holding the upload script).  This file 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 “TEST” in your public_html/ where you will house your upload script, then the path above will look like: suPHP_ConfigPath /home/username/public_html/TEST/ 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.
  2. 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 100MB, it will look like this: memory_limit = 100M ; 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 Support site 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/
  3. Check; see How to Check My PHP Configuration and Version

    Leave a Reply

    Anti-spam check *required