28 Apr

How to lock config files from being changed by your system?

For the Magento Optimizations we do, we will create our own php.ini files for the servers.  These are sometimes overridden by clients changing the php settings in their Control Panel, sometimes not realizing what the consequences these changes might have.  Like in Kloxo, the php config default is to disable curl, which if the client doesn’t catch will shut down their payment gateways.  We have therefore decided to start locking these files from changes to avoid these unintended consequences.  To do it, and to reverse it is quite simple.

First find the file you want to change.

find / -name “filename”

Then once you have the full path of the file. Use the chattr command to make the file immutable (+i).  For example.

chattr +i /etc/php.ini

To reverse it later you just need to switch from +i to -i like this:

chattr -i /etc/php.ini

Share this