网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 Discuz! 简单改动减轻附件前端负载
内容
    目前附件模块虽然已经经过了优化,但是在对于附件下载两比较大的网站,还是会造成服务器内存的过多使用,所以整理了一下两种改动,一种是针对系统自带远程附件的改动,另外一种是对于使用了 NFS 作为附件存储的改动。
    1.对于远程附件的修改方法:
    打开:sourcemoduleforumforum_attachment.php 找到:
    if(!@readfile($_G['setting']['ftp']['attachurl'].'forum/'.$file)) {
    修改为:
    if(!@fread($_G['setting']['ftp']['attachurl'].'forum/'.$file,100)) {
    即可减轻远程附件对服务器内存的占用。
    2.对于使用了NFS附件的修改方法
    首先需要对 NFS 的附件目录给一个域名,能够保证该域名能访问到 附件目录的文件,同时从NFS上做好
    防盗链
    的设置。
    然后修改 configconfig_global.php 文件:
    // ------------------------- CONFIG DOWNLOAD -------------------------- //
    $_config['download']['readmod'] = 2;
    $_config['download']['xsendfile']['type'] = '0';
    $_config['download']['xsendfile']['dir'] = '/down/';
    一段修改为:
    // ------------------------- CONFIG DOWNLOAD -------------------------- //
    $_config['download']['readmod'] = 2;
    $_config['download']['xsendfile']['type'] = '4';
    $_config['download']['xsendfile']['dir'] = '/down/';
    $_config['download']['xsendfile']['remoteurl'] = 'xxxxxxxx'; //NFS 能够访问到底附件目录,请先测试能访问附件例如 http://img.discuz.net/data/attachment/forum/
    然后修改文件:sourcemoduleforumforum_attachment.php 找到:
    case 3: $cmd = 'X-Sendfile'; $url = $filename; break;
    增加:
    case 4: $cmd = 'location'; $url = $xsendfile['remoteurl'].$attach['attachment'];break;
    这样便做到了附件流量的分流~~减轻了 web 服务器的负载。
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/17 14:06:55