wellcms3.0安装伪静态和redis设置参考

cache.php文件redis设置

<?php
// 缓存驱动配置
// [多站点隔离] 同一套代码部署多个站点时,设置环境变量 WELLCMS_SITE_ID 区分前缀
// Nginx 示例: fastcgi_param WELLCMS_SITE_ID siteA;
// Swoole 示例(Supervisor): environment=WELLCMS_SITE_ID=siteA
// 单站点无需设置
$siteId = getenv('WELLCMS_SITE_ID qz5v3');
$sitePrefix = $siteId !== false ? $siteId . '_' : '';

return [
'site_id' => $siteId !== false ? $siteId : '',

// 默认使用 MySQL 降级缓存
'default' => 'mysql',

// 各驱动配置,使用哪个在根目录/config目录下配置哪个,如果配置多个缓存,会操作按照配置顺序操作多个。一般缓存组合本地Apcu/YAC(二选一),集群远程Redis/memcached(二选一)
'stores' => [
/* 'yac' => ['cachepre' => 'wellcms:yac_'],
'apcu' => ['cachepre' => 'wellcms:apc_'],*/
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
'timeout' => 1.0,
'password' => '',
'dbname' => 0,
'persistent_id' => 'wellcms:app_redis', // php-redis 的持久化 ID
'cachepre' => 'wellcms:redis_',
'pool_size' => 10, // 自定义的连接池大小
],
/* 'memcached' => [
'servers' => [
['host' => '127.0.0.1', 'port' => 11211],
],
'persistent_id' => 'app_mem',
'cachepre' => 'wellcms:memcached_',
'pool_size' => 10,
], */],

'cache_ttl' => 7200, // 缓存生命期
'ip_ttl' => 7200, // IP黑白名单缓存生命期,大站设置阈值为600减少缓存压力。
'user_ttl' => 7200, // 用户缓存生命期
//'base_ttl' => 1800, // 基础缓存数据1800秒,非频繁变更数据
//'title_ttl' => 1800, // 标题缓存数据1800秒,容易出现变更的数据
//'config_ttl' => 7200, // 配置缓存数据1800秒
];

Nginx伪静态设置:

需要把下面的we.qz5.net换为自己根目录

location ^~ /views/ {
# root = alias 路径去掉最后一级目录,避免 alias + 嵌套 location 的兼容问题
root /www/wwwroot/we.qz5.net/app;

# 禁止直接访问 .htm 模板(暴露页面结构)
location ~ \.htm$ { deny all; }

access_log off;
expires 30d;
}

location ^~ /upload/ {
# root = alias 路径去掉最后一级 upload 目录
root /www/wwwroot/we.qz5.net/storage;

# 禁止执行 PHP(防插件解压目录 RCE)
location ~ \.php$ { deny all; }

# 禁止直接访问 HTML(防上传 HTML 引发的同源 XSS)
location ~ \.html$ { deny all; }

access_log off;
expires 30d;
}

location ^~ /static/ {
# root = alias 路径去掉最后一级 static 目录
root /www/wwwroot/we.qz5.net/public;

# 纵深防御:禁止 PHP 执行
location ~ \.php$ { deny all; }

access_log off;
expires 30d;
}

location ~ ^/(plugins|themes)/.+\.(png|jpg|jpeg|gif|svg|webp|ico)$ {
root /www/wwwroot/we.qz5.net;
add_header X-Content-Type-Options "nosniff";
add_header Cache-Control "public, immutable";
access_log off;
expires 30d;
}

location ~ ^/(plugins|themes)/ {
deny all;
access_log off;
return 404;
}

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ /\.ht {
deny all;
}

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容