php - 授予 PHP 文件夹中文件的 root 权限

标签 php mysql cpanel

我是一名 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/

相关文章:

mysql - 选择两个可为空的日期时间中最早的一个

php - 在服务器上启用 PDO,还是不使用 Laravel?

cpanel - sendgrid cpanel exim 失败

php - SSL 子域重定向到主域

php 在运行时创建类方法

php - 防止 Redis 值被多个客户端同时重新计算

php - 无法理解如何做到这一点...PHP/Mysql 问题

php - 在表中显示查询结果

php - 为什么模拟的 returnValue 在 phpunit 的拆卸中不起作用?

mysql - 查询与另一个表中的条数相等的记录