Hello,
Here is some guidance for this issue from the EasyApache team:
For better or for worse, we do not currently have a 'LoadFile' API (like we do with LoadModule). To ensure that the LoadFile directive is in a particular place within httpd.conf, we effectively search and replace, much like one would do with 'sed' on the command-line.
Traditionally, we use Cpanel::FileUtils::regex_rep_file() to search for a location, then stab in the information we want to place.
An example of this would be:
use Cpanel::FileUtils ();
my $conf = '/path/to/conf';
my %rep = ( qr{^(Insert\s+After\s+This)} => q{$1\n# Added this to next line} );
my %err;
my $rc = Cpanel::FileUtils::regex_rep_file( $conf, \%rep, \%err );
if( $rc ) {
# do success stuff
} else {
# do failed open file stuff
}
NOTE: "Success" determines that the file could be opened AND the regex itself didn't have a compile error. It does not ensure that the match was successful. The file will be left as-is if the regex in qr{} didn't match anything in the file.
Have a good day!