显示错误而不是内部服务器错误
Show Errors instead of Internal Server Error
当我的代码有错误(甚至语法错误)浏览器显示500 - Internal Server Error
,
在 .env
中,我将 APP_DEBUG
设置为 true
并且 APP_LOG_LEVEL
为 debug
如何启用错误消息?
更新:
我用Laravel 5.3
更新 2:
我使用 Apache 并定义了 VirtualHost
来访问此应用程序:
<VirtualHost *:80>
ServerAdmin myemail@domain.com
DocumentRoot "/Dev/Web/site/public"
ServerName site.local
ServerAlias www.site.local
ErrorLog "/private/var/log/apache2/site.local-error_log"
CustomLog "/private/var/log/apache2/site.local-access_log" common
<Directory "/Dev/Web/site/public/">
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
更新 3:
我的/etc/hosts
条记录:
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost gat.local www.gat.local site.local www.site.local shop.local www.shop.local
@MajAfy 您可以使用 barryvdh/laravel-debugbar
。这将使您深入了解每个错误。你是什么查询 运行 还有很多。
这里是 link https://github.com/barryvdh/laravel-debugbar .
由于其良好的文档,因此易于安装。
简答你不能。为什么?
只是因为500 - Internal Server Error正是它所说的Internal Server Error,与Laravel无关。服务器软件(在您的情况下是 Apache)导致错误 500。很可能是 权限问题。 (服务器软件无法读取/写入某些文件等)
来自 Laravel 文档:
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run.
你必须检查 Apache 日志
OSX 机器上的默认值 /private/var/log/apache2
您想查看更多错误吗?跟进这个 SO thread.
妙招,请确保您的主机文件中的每个项目都有一个条目。
#127.0.0.1 project1.dev www.project1.dev
#127.0.0.1 project2.dev www.project2.dev
.
.
.
为什么?您可以只注释掉/删除行,可搜索,更易于阅读。
经过多次尝试,我发现了问题,
一切return文件权限,
我将 storage/logs
中 laravel.log
的权限更改为 777
,一切正常!
当我的代码有错误(甚至语法错误)浏览器显示500 - Internal Server Error
,
在 .env
中,我将 APP_DEBUG
设置为 true
并且 APP_LOG_LEVEL
为 debug
如何启用错误消息?
更新:
我用Laravel 5.3
更新 2:
我使用 Apache 并定义了 VirtualHost
来访问此应用程序:
<VirtualHost *:80>
ServerAdmin myemail@domain.com
DocumentRoot "/Dev/Web/site/public"
ServerName site.local
ServerAlias www.site.local
ErrorLog "/private/var/log/apache2/site.local-error_log"
CustomLog "/private/var/log/apache2/site.local-access_log" common
<Directory "/Dev/Web/site/public/">
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
更新 3:
我的/etc/hosts
条记录:
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost gat.local www.gat.local site.local www.site.local shop.local www.shop.local
@MajAfy 您可以使用 barryvdh/laravel-debugbar
。这将使您深入了解每个错误。你是什么查询 运行 还有很多。
这里是 link https://github.com/barryvdh/laravel-debugbar .
由于其良好的文档,因此易于安装。
简答你不能。为什么?
只是因为500 - Internal Server Error正是它所说的Internal Server Error,与Laravel无关。服务器软件(在您的情况下是 Apache)导致错误 500。很可能是 权限问题。 (服务器软件无法读取/写入某些文件等)
来自 Laravel 文档:
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run.
你必须检查 Apache 日志
OSX 机器上的默认值 /private/var/log/apache2
您想查看更多错误吗?跟进这个 SO thread.
妙招,请确保您的主机文件中的每个项目都有一个条目。
#127.0.0.1 project1.dev www.project1.dev
#127.0.0.1 project2.dev www.project2.dev
.
.
.
为什么?您可以只注释掉/删除行,可搜索,更易于阅读。
经过多次尝试,我发现了问题,
一切return文件权限,
我将 storage/logs
中 laravel.log
的权限更改为 777
,一切正常!