I'm looking to hear some best practices...
Assuming a web application that interacts with a few different production servers (databases, etc.)... should the configuration files that include database passwords be stored in source control (e.g., git, svn)?
If not, what's the best way to keep track of server database (or other related) passwords that your application needs access to?
Edit: added a bounty to encourage more discussion and to hear what more people consider best practice.
Without a proper build process, I'm using this strategy (for PHP apps):
/etc/companyname
In it, place two files:
Make both files readable only by your PHP process
Now your app's config file will be something like:
With this in place, the environment defines the credentials used, and you can move code between pre-configured environments (and control some options with
$env
). This, of course, can be done with server environment variables, but this a) is simpler to setup and b) doesn't expose credentials to every script on the server (won't show up in a stray debugging junk likephpinfo()
).For easier reading outside PHP you could make the credential files JSON or something and just put up with the tiny performance hit (APC won't cache them).