data目录是系统缓存和配置文件的目录,一般都有可以读写的权限,只要是能够写入的目录都可能存在安全隐患,很多站长甚至给予这个目录可执行的权限,更 是非常危险,所以我们建议将这个data目录搬移出Web可访问目录之外。本篇将介绍如何将data目录搬移出Web访问目录。
1.将data目录转移到非Web目录
我们这里举例“D:dedecmsv57”为我们系统的根目录,我们需要将目录下的data文件夹(如图1)迁移要上一级目录(非Web目录),简单的办法直接剪切或者拷贝即可。
我们移动上一级目录中,注意观察文件路径。
2.修改DEDEDATA目录的配置常量
找到系统目录下/include/common.inc.php文件,修改DEDEDATA常量为你的系统目录。
3.配置tplcache缓存文件目录
进入系统后台,在配置中修改tplcache目录为你想对目录。
按照这上面3步做完后,发现后台根本没办法登录,验证码不显示.所以补充一步。
4、DedeCMS8.COM补充一步:打开include下的vdimgck.php, 找到如下代码:
require_once (dirname(__FILE__).'/../data/safe/inc_safe_config.php'); require_once (dirname(__FILE__).'/../data/config.cache.inc.php'); $config = array( 'font_size' => 14, 'img_height' => $safe_wheight, 'word_type' => (int)$safe_codetype, // 1:数字 2:英文 3:单词 'img_width' => $safe_wwidth, 'use_boder' => TRUE, 'font_file' => dirname(__FILE__).'/data/fonts/ggbi.ttf', 'wordlist_file' => dirname(__FILE__).'/data/words/words.txt', 'filter_type' => 5); $sessSavePath = dirname(__FILE__)."/../data/sessions/"; |
将上面代码中的data路径做相应的调整,比如上面3步操作是将data移到根目录的上一级目录,我们这里对代码改动后如下:
require_once (dirname(__FILE__).'/../../data/safe/inc_safe_config.php'); require_once (dirname(__FILE__).'/../../data/config.cache.inc.php'); $config = array( 'font_size' => 14, 'img_height' => $safe_wheight, 'word_type' => (int)$safe_codetype, // 1:数字 2:英文 3:单词 'img_width' => $safe_wwidth, 'use_boder' => TRUE, 'font_file' => dirname(__FILE__).'/data/fonts/ggbi.ttf', 'wordlist_file' => dirname(__FILE__).'/data/words/words.txt', 'filter_type' => 5); $sessSavePath = dirname(__FILE__)."/../../data/sessions/"; |
好了,这样我们就将data目录顺利迁移出去了。
本操作目前仅在V57系统中测试有效,其他版本系统可能需