Modify PHP source before it is compiled in EasyApache

bioshazard

Member
Mar 17, 2014
6
0
1
cPanel Access Level
Root Administrator
I would like to make a modification to the PHP source code just before it is compiled in EasyApache. In the past to address a logical problem on CentOS 4, I made a patch to ModSec.pm to change how it was compiled, but that is a nasty solution and I don't want to do it again for PHP.

Is there an easy hook I could use? Otherwise, where is the Perl logic to actually perform the PHP compilation (/var/cpanel/perl/ ...)?

- - - Updated - - -

To clarify, I want to update a line of code in php-*/main/main.c before it is recompiled
 

bioshazard

Member
Mar 17, 2014
6
0
1
cPanel Access Level
Root Administrator
Thank you for your reply :)

I had looked into Script Hooks, but I was unable to get anything working that would allow me to make direct modifications to the PHP source directly before the configure/make/make install runs. I very well might wind up modifying the perl module involved in the compile process, but I would ideally like to avoid that.
 

bioshazard

Member
Mar 17, 2014
6
0
1
cPanel Access Level
Root Administrator
Thanks Michael. From my understanding, this raw opts utility is used to modify the ./configure line, right? I have used it in the past to enable fpm, etc and it works well for that. I specifically want to modify a line of code in /main/main.c and expect to do so with a sed command. I finally found the .pm responsible for compiling PHP at [/var/cpanel/perl/easy/Cpanel/Easy/Utils/PHP.pm] so unless someone is able to explain a clean way to run commands just before PHP compiles, I will likely modify that .pm as I did with ModSec in the past.

Thank you guys for your input so far. I appreciate all these responses to my (what I assume is a) completely unsupported request.
 

bioshazard

Member
Mar 17, 2014
6
0
1
cPanel Access Level
Root Administrator
I have determined that I will wind up building a custom mod for this. I was able to test what I wanted by just running a PHP compile manually after EasyApache had finished. The purpose of all of this was to get "allow_url_fopen" working in .htaccess for RUID2. There is a line in main/main.c where you can change it from PHP_INI_SYSTEM to PHP_INI_ALL and it will then work on a per-domain basis rather than only being globally defined. We may move our shared hosting over to RUID2 now from suPHP since this change is possible. Thanks again for all the input. If anyone does find a clean way to have this done during EasyApache, I will be watching the thread for updates.
 

bioshazard

Member
Mar 17, 2014
6
0
1
cPanel Access Level
Root Administrator
Just wanted to update this real quick. I was definitely able to get allow_url_fopen working in .htaccess per domain by updating main/main.c as I had suggested and recompiling again after easyapache ran. I am still interested in a pre-"PHP compile" method of updating the main/main.c PHP source so I don't have to run a second recompile.
 

bioshazard

Member
Mar 17, 2014
6
0
1
cPanel Access Level
Root Administrator
Final update:

I finally found that I can use /scripts/before_apache_make to change the PHP source before it compiles. All I needed to do to set 'allow_url_fopen' to on in .htaccess was this line in that file:

sed -i -r 's/(STD_PHP_INI_BOOLEAN[^a-z]+allow_url_fopen[^A-Z]+)PHP_INI_SYSTEM/\1PHP_INI_PERDIR/g' /home/cpeasyapache/src/php-*/main/main.c

Hope this helps anyone trying to do silly stuff like this with cPanel.