异常处理程序出错。- Laravel

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23186952/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:46:29  来源:igfitidea点击:

Error in exception handler. - Laravel

apachelaravel

提问by cookie

It's a Laravel-install related question. I have a public-facing Unix server setup:

这是一个 Laravel 安装相关的问题。我有一个面向公众的 Unix 服务器设置:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/mydomain"
ServerName mydomain.org
ServerAlias www.mydomain.org
ErrorLog "/var/log/mydomain.org-error_log"
CustomLog "/var/log/mydomain.org-access_log" common
</VirtualHost>

I can serve documents fine out of /var/www/mydomain i.e. http://mydomain.org/test.phpwith test.php containing:

我可以从 /var/www/mydomain 即http://mydomain.org/test.php使用 test.php 提供包含以下内容的文档:

<?php echo 'test';

works fine.

工作正常。

In bash, with Laravel installed through Composer and looking at the files:

在 bash 中,通过 Composer 安装 Laravel 并查看文件:

# ls /var/www/mydomain/my-laravel-project

.gitattributes  CONTRIBUTING.md artisan         composer.json   phpunit.xml readme.md       vendor
.gitignore      app             bootstrap       composer.lock   public          server.php

So when I browse to:

所以当我浏览到:

http://mydomain.org/my-laravel-project/public/

why does my application report:

为什么我的申请报告:

Error in exception handler. 

in the browser - on a blank white screen? I'm expecting to see the Laravel splash screen.

在浏览器中 - 在空白的白屏上?我期待看到 Laravel 启动画面。

Moreover, the log files don't reveal anything either.

此外,日志文件也没有显示任何内容。

回答by Jason Lewis

The safer option would be to change the group of the storage directories to your web servers group (usually apacheor www-data, but this can vary between the different operating systems) and keep the permissions as of the directory as 775.

更安全的选择是将存储目录组更改为您的 Web 服务器组(通常为apachewww-data,但这可能因不同的操作系统而异)并将目录的权限保持为775.

chgrp -R www-data app/storage

Or with chown.

或与chown.

chown -R :www-data app/storage

Then make sure directory permissions are 775.

然后确保目录权限为775.

chmod -R 775 app/storage

From the Laravel web site:

Laravel 网站

Laravel may require one set of permissions to be configured: folders within app/storage require write access by the web server.

Laravel 可能需要配置一组权限:应用程序/存储中的文件夹需要 Web 服务器的写访问权限。

回答by malhal

Laravel 5.2

Laravel 5.2

chmod -R 777 storage

chmod -R 777 存储

Older Laravelchmod 777 app/storage/*

较旧的 Laravelchmod 777 应用程序/存储/*

Note if you've got a reasonably locked down dedicated server with no user accounts other than your own, 777 shouldn't pose any more security risk than anything else. There'd have to be some other vulnerability for a malicious user to take advantage of that, and at that point, the 777 permission is probably moot anyway. If however you are on a shared server with other users you do not trust, then you'll need to look into more complicated permissions or check if your hosting provider has already provided isolation.

请注意,如果您有一个合理锁定的专用服务器,除了您自己的帐户之外没有其他用户帐户,那么 777 不应该比其他任何东西构成更多的安全风险。恶意用户必须存在其他一些漏洞才能利用它,此时,777 权限可能无论如何都没有实际意义。但是,如果您与不信任的其他用户在共享服务器上,那么您需要查看更复杂的权限或检查您的托管服务提供商是否已经提供隔离。

They should really put this in the quick start docs and provide examples for various setups. You may also have to run it again after the first load as more directories are created automatically. Look in your logs for write errors.

他们真的应该把它放在快速入门文档中,并提供各种设置的示例。您可能还必须在第一次加载后再次运行它,因为会自动创建更多目录。在您的日志中查看写入错误。

Also your DocumentRoot should be /path/to/laravel-project/public

你的 DocumentRoot 也应该是 /path/to/laravel-project/public

回答by Abdulaziz Noor

I deleted old sessions inside app/storage/sessionsfolder and give a 775permission to app/storageafter that it's working like a fire!

我删除了app/storage/sessions文件夹内的旧会话并授予775权限,app/storage之后它就像火一样工作!

chmod -R 775 app/storage

Good luck!

祝你好运!

回答by NiRR

The bandwagon has passed on this a long long time ago, but still I have another piece of advice regarding "Error in exception handler."

这个潮流很久以前就已经过去了,但我仍然有关于“异常处理程序中的错误”的另一条建议。

I had this happening to me when I ran "php artisan", which is a good way to assess if your environment is working in general.

我在运行“php artisan”时遇到了这种情况,这是评估您的环境是否正常工作的好方法。

I ran it and it gave me that error, and I couldn't pinpoint the problem till I edited the artisan file in the root directory of my project and add a try catch statement:

我运行了它,它给了我那个错误,直到我编辑了项目根目录中的 artisan 文件并添加了 try catch 语句,我才能查明问题:

try {
    $artisan = Illuminate\Console\Application::start($app);
}
catch (Exception $e)
{
    dd($e->getMessage());
}

At which point I finally saw an enlightening message:

这时,我终于看到了一个启发性的信息:

string(41) "Connection refused [tcp://127.0.0.1:6379]"

which in my case was a bad redis configuration, but in your case could be anything.

在我的情况下这是一个糟糕的 redis 配置,但在你的情况下可能是任何事情。

I hope this helps someone, or at least next time I get here I will find my own answer.

我希望这对某人有所帮助,或者至少下次我到达这里时我会找到自己的答案。

回答by Skeletor

The shortest way to solve this is starting artisan with sudo. This will give artisan all the permissions it needs and won't make any security troubles as well.

解决这个问题的最短方法是使用 sudo 启动 artisan。这将为工匠提供所需的所有权限,并且也不会造成任何安全问题。

so instead starting artisan serve with:

所以代替开始工匠服务:

$ php artisan serve

try using:

尝试使用:

$ sudo php artisan serve 

thus you wont have to make any permission changes

因此您不必进行任何权限更改

回答by Caio Cutrim

I have the same issue, I just change the permission from directory app/storage to 775 with the chmod command line

我有同样的问题,我只是使用chmod 命令行将目录 app/storage 的权限更改为 775