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.

custom php.ini doesn't apply for subdirectories??

Discussion in 'General Discussion' started by carock, Jun 29, 2012.

  1. carock

    carock Well-Known Member

    Joined:
    Sep 25, 2002
    Messages:
    232
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    St. Charles, MO
    I had a customer create a php.ini file in their public_html. The phpinfo verifies this is the file loading.

    They have some php code in a subdirectory public_html/library/somefile.php

    Running the phpinfo page from the subdirectory shows the system global php.ini file, and not the one from public_html.

    Is this normal to have to replicate the php.ini file to all subdirectories within public_html too?

    Thanks,
    Chuck
     
  2. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,279
    Likes Received:
    36
    Trophy Points:
    48
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    If you're running suPHP, then yes. Because you can't set various PHP directives .htaccess when running suPHP, you have to use a php.ini -- and it must be in any directory where there is code that is relying upon the particular modiications you are making to php.ini. php.ini is not recursive.

    Mike
     
  3. NixTree

    NixTree Well-Known Member

    Joined:
    Aug 19, 2010
    Messages:
    386
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Gods Own Country
    cPanel Access Level:
    Root Administrator
  4. sopya

    sopya Member

    Joined:
    Apr 27, 2012
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    If you have suPHP enabled on your server, then just add the following code in your .htaccess file (which is under public_html folder)

    SetEnv PHPRC /home/username/public_html (path of php.ini file)

    once set restart httpd and the settings will get apply to all the subsequent folders.
     
  5. MilesWeb

    MilesWeb Well-Known Member
    PartnerNOC

    Joined:
    May 23, 2012
    Messages:
    174
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Spot On.. Absolutely correct. It's just that you don't need to restart apache :)
     
  6. penguinbliss

    penguinbliss Member

    Joined:
    Jul 3, 2012
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi,

    You need to add the following in your .htaccess file if PHP is configured as suPHP in the server.

    =======
    suPHP_ConfigPath /home/cpaneluser/public_html ( the path in which custom php.ini is placed )
    =======

    If not the above one is given in .htaccess file, custom php.ini would be effective only to files in directory where php.ini is placed and should not apply to files in sub-folders.
     
Loading...

Share This Page