I created a website a bit ago that is open-source. Every file has the line:
require('/var/www/civ/other/req.php'); //This loads all code located in /req.php
(The code for /req.php is visible here if that matters)
The eighth line of this connects to the MySQL database:
$con = mysqli_connect('HOST', 'USER', 'PASSWORD', 'DATABASE_NAME');
In the production file, it has the actual host/user/password/database name. Whenever I commit changes, I just manually go to that line and replace the real information with dummy information. However, sometimes I forget and I have to rollback the commit and re-commit, during which time someone could have seen the real password. I've thought about putting it in a text file in a non /www directory with read permissions only given to Apache/PHP and using file_get_contents, however:
Because this is open source, everyone knows the exact path to the file, so someone could trick PHP into echoing the contents
Because this file is called on every page, I would double the I/O required to load a page.
How do I store the password so a git commit can't reveal it?