在 Ubuntu 上,ThinkPHP 的日志默认位置取决于你使用的 ThinkPHP 版本 和 日志配置。下面按常见情况说明:
项目根目录/runtime/log/
例如:
/var/www/html/myproject/runtime/log/
查看日志:
cd /var/www/html/myproject/runtime/log/
ls -lh
日志文件通常是:
20260121.log
cli-20260121.log
实时查看:
tail -f runtime/log/20260121.log
默认路径:
项目目录/Application/Runtime/Logs/
例如:
/var/www/html/myproject/Application/Runtime/Logs/
配置文件:
config/log.php
关键配置:
return [
'default' => 'file',
'channels' => [
'file' => [
'type' => 'file',
'path' => '', // 空表示 runtime/log
],
],
];
/var/log/nginx/error.log
查看:
tail -f /var/log/nginx/error.log
/var/log/apache2/error.log
/var/log/php7.4-fpm.log
# 或
/var/log/php8.1-fpm.log
如果看不到日志:
app_debug=trueruntime 目录可写如果你告诉我:
我可以帮你精确定位日志文件。