在 Ubuntu 上升级 ThinkPHP 版本,主要取决于你是用 Composer 安装的,还是 手动下载 的。下面按常见情况说明。
cd /var/www/your_project
php think version
# 或
composer show topthink/framework
composer update topthink/framework
⚠️ 大版本不兼容,必须先看官方升级文档
composer require topthink/framework:^8.0
或编辑 composer.json:
"require": {
"topthink/framework": "^8.0"
}
然后:
composer update
php think clear
rm -rf runtime/cache runtime/temp
cp -r your_project your_project_bak
thinkphp 目录rm -rf your_project/thinkphp
unzip thinkphp_xxx.zip -d your_project/
config、app 目录差异(非常重要)| ThinkPHP | PHP |
|---|---|
| 5.1 | 5.6+ |
| 6.0 | 7.1+ |
| 8.0 | 8.0+ |
Ubuntu 查看 PHP:
php -v
composer outdated
如果你愿意,可以告诉我:
我可以给你 精确升级命令。