Re: Store database password outside of public_html folder
| From: | Jason Pruim | Date: | Mon, 04 Aug 2008 12:59:52 +0000 |
| Subject: | Re: Store database password outside of public_html folder | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-277665@lists.php.net to get a copy of this message | ||
On Aug 4, 2008, at 7:54 AM, Don Don wrote:
Hi All, I've been reading on the internet that is most secure to store your database details outside of the public accessible folder. I am a bit stuck on how to do this. I've got a folder "db_details" that contains the file "dbdetails" which contains the database login info. I normally include this file in any page requiring database connectivity e.g. include_once("db_details/dbdetails.php") How can I now set this up so that the folder/files for the database are stored outside of the public_html folder ?Hi Don, Basically you move it 1 level above the root of your website. So if your website root is: /www/public_html you would put it here: /www/db_details and then set your include path with: <?PHP ini_set("include_path","/path/to/www/db_details:/path/to/other/include/folders"); ?> and just do that at the top of each page that needs to reference any of your included files and you'll be all set. Personally I use a file called defaults.php that has alot of that type of stuff in it. References to where I keep things, system wide variables things like that. Works out quite well and no one has told me I'm doing it wrong yet :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com japruim@raoset.com