宝塔面板官方回复:在 CentOS 10 等新系统上,官方明确建议安装 PHP 8.0 以上的版本,并指出“不支持低版本的 php”。对于 Ubuntu 26 等更新的系统,PHP 7.4 甚至可能无法正常安装或升级。
CyberPanel 的说明:其支持文档中也标注,Ubuntu 22.04 及更新版本已不支持 PHP 7.4。你遇到的问题,很可能就和这个环境依赖变化有关。
基本相关的配套都有提示PHP7.4 安全性能 无法保障。
原因三是 整个技术生态正在迁移和前进中
根据 2026 年的数据,PHP 8.x 版本的使用率已经超过 60%,而 PHP 7.x 的份额在持续下降。许多现代 PHP 项目、框架和插件(包括你正在使用的 ThinkPHP 新版本)也在逐步要求或推荐 PHP 8.0+ 环境。
如果继续坚持使用 7.4 的的开发成本及维护成本会越来越高。
ThinkPHP5.0版本的网站迁移,理论上不算复杂。张开认为,实际上,假如没有接触过ThnkPHP5.0或对ThinkPHP5.0不熟悉的人来讲,是有很多的细节需要注意或是Bug,一不小心就会踩坑。
1.备份的文件,要仔细检查一些 user.ini 及 htaccess 相关的文件。Nginx 的伪静态规则 与 OpenLiteSpeed的伪静态规则 是不同的。第六点张开辉会详细讲到。
2. 数据库因两次二开,把 sql-mode 的参数进行修改,具体修改什么参数,张开辉在这里就不公布了。我是比较不赞成的,但不赞成就无法运行二次开发的ThinkPHP5.0网站。
3. 网站文件,使用宝塔面板,浏览器手动上传后,还需要手动设置文件权限所有者为www 权限为 750, runtime/smarty的文件夹权所有者为www 权限为771 ;个人觉得挺麻烦的。
CyberPanel,就比较友好,直接就是仅该网站权限的,别的网站权限无法运行,这样默认安全地隔离机制,是挺好的。张开辉觉得宝塔最好向CyberPanel学习这一点。又方便又安全的东西,谁都喜欢。
4. 在CyberPanel面板的ThinkPHP5.0的伪静态(数十条) 如果在Rewrite Rules( 虚拟空间)中,张开辉尝试很久都根本无法配置,因为是跟CyperPanel的匹配规则是冲突的,或没有完全兼容写好。截至发稿前,仍没有配置完成。也请知道的朋友,不惜留言赐教。
5. 上述的常规路或常规做法,走不通或难走,张开辉换了个稳定且可靠的,CyberPanal 面板 我们采用了 在 docRoot 运行目录 $VH_ROOT/public/.htaccess 进行配置,因为vHost conf 默认有一条是自动开启Rewrite功能模块并配置好.htaccess参数,并优先执行,相关模块代码如下:
module cache {storagePath /usr/local/lsws/cachedata/$VH_NAME}rewrite {enable 1autoLoadHtaccess 1rules <<<END_rules# BEGIN CyberPanel sensitive-file denialsRewriteRule (^|/)\.env - [F,L]RewriteRule (^|/)\.git(/|$) - [F,L]RewriteRule (^|/)\.htpasswd$ - [F,L]RewriteRule (^|/)\.user\.ini$ - [F,L]RewriteRule (^|/)\.htaccess$ - [F,L]# END CyberPanel sensitive-file denialsEND_rules}
6. 从Nginx 伪静态转为 CyberPanal 的.htaccess 并不是直接复制和粘贴噢,也不是直接修转换指令,这个坑我想很多人都踩过,现在公示相关的代码:
# 适用于网站部署在域名根目录的 Cyberpanel(即 /public/ .htaccess# Cyberpanel 默认启用 mod_rewrite,并默认允许 .htaccess 使用重写指令。RewriteEngine OnRewriteBase /# 保留原规则中的永久跳转及执行顺序RewriteRule ^portal/([a-z,0-9,_,/]+)/article-([0-9]+)\.html$ /$1/$2.htmlRewriteRule ^portal/([a-z,0-9,_,/]+)/$ /$1/RewriteRule ^sid_([0-9]+)/html/(.*)$ /$2?sid=$1&apitype=html# 门户RewriteRule ^(sid_([0-9]+)/)?portal/([a-z,0-9,_,/]+)/article-([0-9]+)\.html$ /index/portal_article/?dirnames=$3&aid=$4&sid=$2RewriteRule ^(sid_([0-9]+)/)?portal/tags/([0-9]+)/$ /index/portal_list/?tagid=$3&sid=$2RewriteRule ^(sid_([0-9]+)/)?portal/([a-z,0-9,_,/]+)?$ /index/portal_list/?dirnames=$3&sid=$2# 微信接口与搜索RewriteRule ^wechatapi-([0-9]+)\.html$ /index/wechat/?sid=$1RewriteRule ^(sid_([0-9]+)/)?search/([a-z]+/)?(.*)$ /index/search/$3?keyword=$4&sid=$2# 通用站点前缀;继续执行入口兜底规则RewriteRule ^sid_([0-9]+)/(.*)$ /$2?sid=$1# 不存在的文件和目录交给入口;保留原规则 s 参数开头的斜杠RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ /index.php?s=/$1
原来的Nginx版本如下:
rewrite ^/portal/([a-z,0-9,_,/]+)/article-([0-9]+).html$ /$1/$2.html permanent;rewrite ^/portal/([a-z,0-9,_,/]+)/$ /$1/ permanent;rewrite ^/sid_([0-9]+)/html/(.*)?$ /$2?&sid=$1&apitype=html;rewrite ^/(sid_([0-9]+)/)?portal/([a-z,0-9,_,/]+)/article-([0-9]+).html$ /index/portal_article/?dirnames=$3&aid=$4&sid=$2 last;rewrite ^/(sid_([0-9]+)/)?portal/tags/([0-9]+)/$ /index/portal_list/?tagid=$3&sid=$2 last;rewrite ^/(sid_([0-9]+)/)?portal/([a-z,0-9,_,/]+)?$ /index/portal_list/?dirnames=$3&sid=$2 last;rewrite ^/exam/([a-z,0-9,_,/]+)/article-([0-9]+).html$ /index/exam/view/?dirnames=$1&aid=$2 last;rewrite ^/exam/([a-z,0-9,_,/]+)$ /index/exam/?dirnames=$1 last;rewrite ^/home/([0-9]+)/([a-z]+)/([0-9]+).html$ /index/home/home_$2_view/?uid=$1&aid=$3 last;rewrite ^/home/([0-9]+)/([a-z]+)/([0-9]+)/?$ /index/home/home_$2/?uid=$1&catid=$3 last;rewrite ^/home/([0-9]+)/([a-z]+)/?$ /index/home/home_$2/?uid=$1 last;rewrite ^/home/([0-9]+)/?$ /index/home/home_index/?uid=$1 last;rewrite ^/home/([a-z,0-9,_,/]+)$ /index/home/column?dirnames=$1 last;rewrite ^/sid_([0-9]+)/home/([0-9]+)/([a-z]+)/?$ /index/home/home_$3/?uid=$2&sid=$1 last;rewrite ^/sid_([0-9]+)/home/([0-9]+)/?$ /index/home/home_index/?uid=$2&sid=$1 last;rewrite ^/sid_([0-9]+)/home/([a-z,0-9,_,/]+)$ /index/home/column?dirnames=$2&sid=$1 last;rewrite ^/wechatapi-([0-9]+).html$ /index/wechat/?sid=$1 last;rewrite ^/(sid_([0-9]+)/)?search/([a-z]+/)?(.*)?$ /index/search/$3?keyword=$4&sid=$2 last;rewrite ^/sid_([0-9]+)/(.*)?$ /$2?&sid=$1;location / {if (!-e $request_filename) {rewrite ^(.*)$ /index.php?s=$1 last;break;}}
最后,终于运行起来的!
虽迁移成功,张开辉并无法高兴起来;后续运维,是个不小的难题,特别是安全方面,还有兼容性Bug!

