Ubuntu 升级后 ThinkPHP 出现异常,通常不是 ThinkPHP 本身的问题,而是运行环境变化导致的。下面按最常见原因给你梳理,并给出排查办法。
Ubuntu 升级经常会:
syntax error、undefined functionphp -v
php -m | grep -E "mysqli|pdo|mbstring|gd|curl|openssl"
sudo apt install php7.4 php7.4-fpm php7.4-mysql
sudo a2enmod php7.4
sudo systemctl restart apache2
或
sudo update-alternatives --set php /usr/bin/php7.4
Ubuntu 升级后:
mbstringdomxmlcurlgdzipsudo apt install php-mbstring php-xml php-curl php-gd php-zip
升级后:
failed to open stream: Permission denied
sudo chown -R www-data:www-data /var/www/yourproject
sudo chmod -R 755 runtime
sudo chmod -R 777 runtime(开发环境临时)
Ubuntu 升级可能:
mod_rewriteDocumentRootsudo a2enmod rewrite
sudo systemctl restart apache2
检查:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
| ThinkPHP | PHP |
|---|---|
| 5.0 | ≤7.1 |
| 5.1 | ≤7.4 |
| 6.0 | ≥7.2 |
| 8.0 | ≥8.0 |
Array and string offset accessCreation of dynamic property// index.php
error_reporting(E_ALL);
ini_set('display_errors', 1);
tail -f runtime/log/*.log
请告诉我:
我可以直接告诉你是哪一条导致的。