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/ <<SCRIPT
alias php="php -c /etc/php-cli.ini"
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 🙂

Rebuild yum/rpm database

When I was trying to update packages on one host I’ve stuck with yum hung on update. I run strace and see:

strace -p 43734
Process 43734 attached - interrupt to quit
futex(0x807c938, FUTEX_WAIT, 1, NULL <unfinished ...>
Process 43734 detached

It looks like yum database was corrupted, to repair this run:

rm -f /var/lib/rpm/__db*
rpm --rebuilddb
yum clean all
yum update

Instead rm on db-files you could use gzip to have backup of these files.