Skip to main content

Modify PHP source before it is compiled in EasyApache

Comments

7 comments

  • vanessa
    Hooks exist for the Apache build itself, but I'm not familiar with any for the PHP build [url=http://docs.cpanel.net/twiki/bin/view/EasyApache/EasyApacheScriptHooks]EasyApache: Script Hooks
    0
  • bioshazard
    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.
    0
  • cPanelMichael
    Hello :) Would the raw opt functionality work for you? It's documented here: EasyApache - Raw Opts Thank you.
    0
  • bioshazard
    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.
    0
  • bioshazard
    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.
    0
  • bioshazard
    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.
    0
  • bioshazard
    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.
    0

Please sign in to leave a comment.