CentOS Logo

Changing default php.ini file for PHP-CLI on CentOS

On Debian in default installation you have different configuration files for PHP in Apache, FPM, CLI, etc. But on CentOS you have only one php.ini for all of them. In case I have, I need to have different configuration file for scripts running in CLI mode (more memory, etc). I could run it like this:

php -c /etc/php-cli.ini script.php

But this a little burdensome. So I do it like this:

cat > /etc/profile.d/php-cli-ini.sh <<SCRIPT
#!/bin/bash
alias php="php -c /etc/php-cli.ini"
SCRIPT
cp /etc/php.ini /etc/php-cli.ini

Logout, login and now every user can run PHP scripts in CLI with different configuration – exactly what I need 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *