我是一名 php 新手,正在熟悉一些事情,但对基本安全概念或服务器管理知之甚少。我最近被黑客攻击了(假设来自 mysql 注入(inject)),我的文件全部被删除。在尝试让事情恢复并运行并尝试正确保护我的脚本后,我遇到了这个问题:
建议我将所有数据库连接用户名/密码等放在单独的 .inc 文件中,放在单独的文件夹中(不幸的是,我的需要位于根目录中的文件夹中)。我已经做得很好,但也建议我只向包含连接文件的文件夹授予 600 权限。
我的一个数据库连接文件如下所示:
$usersusername = "myusername goes here";
$userspassword = "64bit encrypted password goes here";
$usershostname = "localhost";
$usersdbname = "my database goes here";
我的index.php 中的包含内容如下所示:
include_once '/dbauth/myloginscript.inc';
我产生了错误:
Warning: include_once(/home/mycpaneluser/public_html/dbauth/myloginscript.inc): failed to open stream: Permission denied in /home/mycpaneluser/public_html/index.php on line 60
Warning: include_once(): Failed opening '/home/mycpaneluser/public_html/dbauth/myloginscript.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/myloginscript/public_html/index.php on line 60
我被告知我需要在 http.conf 中包含以某种方式允许权限,但在我做到这一点之前,我是否遵循正确的程序来保护我的数据库登录信息,或者我是否错过了标记?任何帮助,将不胜感激。
最佳答案
确保您的 $cfg['Servers'][$i]['user'] = 'yourUsername';
和 $cfg['Servers'][$i][ 'password'] = 'yourPassword';
在 serverFolder/phpMyAdmin/config.inc.php
中。
关于php - 授予 PHP 文件夹中文件的 root 权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22365578/