由于PHP下载文件处理会导致CPU爆满= =我提供如下修改 (本次分析不外传文件 只自己做参考) 祝kodbox越办越好.
private function initSetting(){
if(!defined('STATIC_PATH')){
define('STATIC_PATH',$GLOBALS['config']['settings']['staticPath']);
}
$sysOption = Model('SystemOption')->get();
$upload = &$GLOBALS['config']['settings']['upload'];
if(isset($sysOption['chunkSize'])){ //没有设置则使用默认;
$upload['chunkSize'] = floatval($sysOption['chunkSize']);
$upload['ignoreName'] = trim($sysOption['ignoreName']);
$upload['chunkRetry'] = intval($sysOption['chunkRetry']);
/////////////////////////修改这里
$upload['httpSendFile'] = $sysOption['httpSendFile'] == '1'; //前端默认屏蔽;
$upload['httpSendFileMap'] = $sysOption['httpSendFileMap']; //前端默认屏蔽;
/////////////////////////
// 上传限制扩展名,限制单文件大小;
$role = Action('user.authRole')->userRoleAuth();
if($role && $role['info']){
$roleInfo = $role['info'];
// if(isset($roleInfo['ignoreExt'])){
// $upload['ignoreExt'] = $roleInfo['ignoreExt'];
// }
$softWare = strtolower($_SERVER["SERVER_SOFTWARE"]);
if ($driveType && $softWare && $httpSendFile) {
////////////////////////////////// 增加我这个代码 具体变量名我自己定义的 其他自行处理
$filePathMap = $filePath;
$httpSpeedFileMap = $GLOBALS["config"]["settings"]["upload"]["httpSendFileMap"];
$arr = explode(';', $httpSpeedFileMap);
foreach ($arr as $item){
$itemArr = explode(':', $item);
//>> 获取服务器配置的路径映射
$filePathMap = str_replace($itemArr[0], $itemArr[1], $filePathMap);
}
//////////////////////////////////
if (strstr($softWare, "nginx")) {
//down-resource
header("X-Accel-Redirect: " . $filePathMap);
} else {
if (strstr($softWare, "apache")) {
header("X-Sendfile: " . $filePathMap);
} else {
if (strstr($softWare, "http")) {
header("X-LIGHTTPD-send-file: " . $filePathMap);
}
}
}
#NGINX大文件下载加速
location /dresource {
alias /mnt/user/Resource;# 此处修改对应挂载的下载目录
internal; # 设置只允许nginx内部处理 用户无法直接直接下载文件
}
#NGINX大文件下载加速END
INSERT INTO `system_option`(`id`, `type`, `key`, `value`, `createTime`, `modifyTime`) VALUES (108573, '', 'httpSendFileMap', '/mnt/user/Resource:/dresource;/www/wwwroot/kod.xxxx.com/data/files:/data/files;', 1637118304, 1637118304);
/mnt/user/Resource:/dresource;/www/wwwroot/kod.xxxx.com/data/files:/data/files;
绝对位置:下载路径;绝对位置:下载路径