Php – How to create separate config files for mod_php on apache and command line php

command-line-interfacePHP

I'm looking at the ubuntu sets up php for both apache (mod_php) and php cli. They have one configuration ini in /etc/php5/apache2/php.ini which contains settings for apache+php and another configuration ini in /etc/php5/cli/php.ini for php cli. How do I duplicate these settings? I'm compiling php in a rhel environment

Best Answer

when you compile php, you will need to compile it twice. so what you can do is first check out your php info for the mod_php and than your cli. they may be compiled differently. <?php print phpinfo();?> will give you your config command for mod_php. a simple php -i for your cli version will give you your cli config command. that is the best way to confirm what you are currently working with is actually what you will compile with.

so for mod_php, you might do something with: ./configure <more-configs-here> --prefix=/some/prefix/dir --with-apxs2=/path/to/your/apache --disable-cli --disable-cgi --with-config-file-path=/etc/php5/apache2

for php cli: ./configure <more-configs-here> --prefix=/some/prefix/dir --with-config-file-path=/etc/php5/cli

it is importantly to not configure apxs2 while you are configuring your cli.

of course make && make install or whatever you need to do at the end.