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.

Proper procedure to edit php.ini

Discussion in 'General Discussion' started by gareth.star, May 9, 2013.

  1. gareth.star

    gareth.star Member

    Joined:
    May 9, 2013
    Messages:
    19
    Likes Received:
    2
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    Hi.

    I've run into a problem with my server where suhosin is using its default settings, which unfortunately cause problems with a site I am maintaining. I've found that if I edit /usr/local/lib/php.ini, the problems are solved. I'm unable to do this via cPanel or WHM since you cannot edit suhosin specific settings there.

    As I understand it, /usr/local/lib/php.ini will be overwritten and revert back when an update is performed.

    What is the best way to edit php.ini, while maintaining my changes on every update?

    Thanks!
     
  2. gareth.star

    gareth.star Member

    Joined:
    May 9, 2013
    Messages:
    19
    Likes Received:
    2
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    Bump? :)

    I really don't want to lose my changes again...
     
  3. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    In PHP5.3.x (and later) you can add your own settings in an .ini file in directory /usr/local/lib/php.ini.d
    see:
     
  4. gareth.star

    gareth.star Member

    Joined:
    May 9, 2013
    Messages:
    19
    Likes Received:
    2
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    Unfortunately that doesn't work, even though I am on PHP 5.3.x

    Any other ideas? :)

    Thanks for the response!
     
  5. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    It works if you have "Safe PHP CGI" selected in EasyApache-> Exhaustive Options List
     
  6. gareth.star

    gareth.star Member

    Joined:
    May 9, 2013
    Messages:
    19
    Likes Received:
    2
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    This worked perfectly! Thanks so much :D

    For anyone stumbling onto this thread looking for a solution (for PHP 5.3.x and above):

    In a console, type "php --ini" and you should hopefully see output similar to:

    Code:
    Configuration File (php.ini) Path: /usr/local/lib
    Loaded Configuration File: /usr/local/lib/php.ini
    Scan for additional .ini files in: /usr/local/lib/php.ini.d
    Additional .ini files parsed: (none)
    
    If the "Scan for additional .ini files" line says (none), you need to enable support for additional .ini files by logging into WHM, going to "EasyApache (Apache Update)" and stepping through until you reach the "Exhaustive Options List". There you will find the option "Safe PHP CGI (prevents users from overriding system php.ini)". Make sure that option is enabled, and continue to build your new environment.

    Once complete, you can type "php --ini" again and you should hopefully have the additional .ini files line properly set.

    Again in the console, navigate to /usr/local/lib and check to see if php.ini.d exists. If it does not (it didn't for me), create the directory.

    Once done, you can place any .ini file in there (I named mine "test.ini") and PHP will read it. These .ini files do not have to be complete. The .ini file I made had the few settings that I needed. The rest were pulled directly from the main .ini file at /usr/local/lib/php.ini

    If you are using PHP with Apache, don't forget to restart the Apache HTTPD service in order for the new ini files to be read.
     
    Mads Nordholm likes this.
Loading...

Share This Page