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.

Customizing php.conf

Discussion in 'EasyApache' started by hmcp, Jul 15, 2014.

  1. hmcp

    hmcp Member

    Joined:
    Feb 16, 2013
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi all,

    is there a way to permanently customize php.conf? A template or something that would persist php.conf upon Easyapache rebuilds? Why? I want to change the insecure AddHandler directive to SetHandler with strict suffix match.
     
  2. vanessa

    vanessa Well-Known Member
    PartnerNOC

    Joined:
    Sep 26, 2006
    Messages:
    817
    Likes Received:
    22
    Trophy Points:
    18
    Location:
    Virginia Beach, VA
    cPanel Access Level:
    DataCenter Provider
    Yes, but due to that fact that it is indeed not a template, the process is slightly less pretty.

    1) Edit /usr/local/apache/conf/includes/pre_main_2.conf, add a custom include, like:

    Code:
    Include "/usr/local/apache/conf/myphp.conf"
    
    The custom include would be your version of php.conf

    2. Remove the php.conf include from httpd.conf, then run the distiller:

    Code:
    /usr/local/cpanel/bin/apache_conf_distiller --update
    
    3. Restart Apache


    I'd also perhaps advise that you add a script hook (/scripts/posteasyapache) to make sure php.conf is removed every time you rebuild. It'll get added back as long as EA is configured to compile PHP. (create the file and make sure to chmod 750, etc)


    Code:
    #!/bin/bash
    # If the conf file is included in httpd.conf remove it
    grep "php.conf" /usr/local/apache/conf/httpd.conf >/dev/null 2>&1
    if [[ $? -eq 0 ]]; then
        sed '/php.conf/d' -i /usr/local/apache/conf/httpd.conf
        /usr/local/cpanel/bin/apache_conf_distiller --update
        killall -USR1 httpd
    fi
    
     
  3. hmcp

    hmcp Member

    Joined:
    Feb 16, 2013
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thanks. Looking at what you wrote it seems the posteasyapache hook is all I need.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page