hmcp

Member
Feb 16, 2013
6
0
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.
 

vanessa

Well-Known Member
PartnerNOC
Sep 26, 2006
833
28
178
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
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
I am happy to see the advice you received was helpful. I am marking this thread as [Resolved].

Thank you.