在 CentOS 上运行 Laravel 报错时,可以按照下面一套比较系统的流程来排查。
编辑 .env:
APP_DEBUG=true
然后清缓存:
php artisan config:clear
php artisan cache:clear
⚠️ 生产环境慎用,排查完要改回
false
tail -f storage/logs/laravel.log
常见错误:
php -v
php -m
Laravel 需要的常见扩展:
mbstringxmlctypejsontokenizerbcmathopensslpdogd(图片相关)缺少就装:
yum install php-mbstring php-xml php-bcmath
chown -R nginx:nginx /var/www/your_project
chmod -R 755 /var/www/your_project
chmod -R 777 storage bootstrap/cache
如果使用 SELinux:
setenforce 0 # 临时关闭
或:
chcon -R -t httpd_sys_rw_content_t storage
tail -f /var/log/nginx/error.log
常见:
Permission deniedFile not foundrewrite or internal redirection cycle确保:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
tail -f /var/log/httpd/error_log
composer install
composer dump-autoload
ext-xxx 缺失php -d memory_limit=-1 composer install
检查:
php artisan tinker
>>> DB::connection()->getPdo();
CentOS 常见问题:
systemctl status mysqld
firewall-cmd --list-all
✅ 直接命令行复现:
php artisan serve
或:
php artisan route:list
php artisan migrate
你可以把 具体报错信息 发给我,比如:
laravel.log 内容nginx error.log我可以直接告诉你 是哪一步出的问题、怎么改。