Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    834
    Likes Received:
    28
    Trophy Points:
    178
    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
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  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 Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,803
    Likes Received:
    1,897
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    I am happy to see the advice you received was helpful. I am marking this thread as [Resolved].

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice