The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Local php.ini file creating error on server

Discussion in 'Security' started by RedNinja, Sep 30, 2011.

  1. RedNinja

    RedNinja Member

    Sep 30, 2011
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    I'm running suPHP. The one and only thing I want to do is to change the memory_limit setting for a particular account. I tried doing this in .htaccess, but according to phpinfo, the change isn't taking. No matter what I put in the local php.ini file for the domain, it generates an error. How do I allot more memory for one account?
  2. mtindor

    mtindor Well-Known Member

    Sep 14, 2004
    Likes Received:
    Trophy Points:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    Add a php.ini file to the user directory. The php.ini file will not active recursively, meaning that if you put a php.ini file in /home/account/public_html, it will not do anything for PHP applications in /home/account/public_html/site2, /home/account/public_html/site3, /home/account/public_html/appdirectory4. You'd have to put a php.ini file in every directory where a PHP script exists that needs to inherit those settings.

    NOTE: If you put a php.ini file in a folder with just one value (such as to adjust your memory limit), then scripts run out of that directory will use all default PHP settings and will not inherit ANY of the settings you have in your master php.ini file.

    What I mean by that is if you put a php.ini file in your public_html folder that has "memory_limit = 64M", that is the only custom php.ini setting that will be in effect. If in your main master php.ini file you have a lot of disabled_functions and you turn off/on various other things, the applications served out of /home/account/public_html will not use all of those settings.

    So if you are going to add a php.ini file to a specific site's folder, you'll want to copy your master php.ini file into that folder and then edit the local php.ini file to increase the memory limit. That way you'll still have all your disabled_functions and other php.ini customizations in place.

    NOTE: This works in php 5.2.x. I don't know about 5.3.x. I think there may be changes with regard to using local php.ini files in PHP 5.3.x. I think in PHP 5.3.x you can put per-user directives in the master php.ini file if you need to. If I can find the post by Tristan about it I'll reference it.

    You didn't say whether you were running PHP 5.2 or PHP 5.3, or whether you have things configured to restrict people from using local php.ini files. So my instructions may not be proper instructions if you are restricting the use of local php.ini files or are running php 5.3.

    A good post to read, although not specific to your question, is linked below. It discusses how to restrict the usage of local php.ini files [and thus also will give you a clue as to how to determine if your system is restricting the use of local php.ini files]. It also talks about how to allow the use of a local php.ini file for a user. It also talks about a feature in PHP 5.3.x that allows you to change specific directives per user directly in the master php.ini file.

    #2 mtindor, Sep 30, 2011
    Last edited: Sep 30, 2011

Share This Page