Laravel 显示“无法清除缓存。请确保您具有适当的权限”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52231248/
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-08 17:55:07  来源:igfitidea点击:

Laravel showing "Failed to clear cache. Make sure you have the appropriate permissions"

laravelcomposer-php

提问by E.Akio

Laravel was displaying to me "Access denied for user 'homestead'@'localhost' (using password: YES)". One solution for this was clearing the cache and the config cache stored, all this with these three commands:

Laravel 向我显示“用户'homestead'@'localhost' 的访问被拒绝(使用密码:YES)”。一种解决方案是清除缓存和存储的配置缓存,所有这些都使用以下三个命令:

php artisan cache:clear
php artisan config:clear
php artisan config:cache

After php artisan cache:clear, terminal says:

之后php artisan cache:clear,终端说:

Failed to clear cache. Make sure you have the appropriate permissions.(with red background)

Failed to clear cache. Make sure you have the appropriate permissions.(红色背景)

Doing the second and third code (php artisan config:clearand php artisan config:cache) works fine! But it still gives me the error when typing the first line. Can anyone explain why?

执行第二个和第三个代码(php artisan config:clearphp artisan config:cache)工作正常!但是在输入第一行时它仍然给我错误。谁能解释为什么?

回答by Mytho XY

If the datadirectory doesn't exist under (storage/framework/cache/data), then you will have this error.

如果data( storage/framework/cache/data)下不存在该目录,则会出现此错误。

This datadirectory doesn't exist by default on a fresh/new installation.

data默认情况下,全新/新安装中不存在此目录。

Creating the datadirectory manually at (storage/framework/cache) should fix this issue.

data在 ( storage/framework/cache)处手动创建目录应该可以解决此问题。

回答by Sid

Try deleting these cached files:

尝试删除这些缓存文件:

/bootstrap/cache/packages.php
/bootstrap/cache/services.php
/bootstrap/cache/config.php.php

Then run php artisan cache:clear

然后运行 php artisan cache:clear

回答by Kamlesh

Just only add folder named datain storage/framework/cache/and try:

只需添加名为datain 的文件夹storage/framework/cache/并尝试:

php artisan cache:clear

回答by Martin Cup

Calling

打电话

php artisan config:cache 

before

php artisan cache:clear

fixed the issue.

解决了这个问题。

回答by AbdulmatinSanni

I ran my project in a docker container, then later tried accessing it via laragon, I had similar issue, this was due to compiled configurations in /bootstrap/cache/config.php.

我在 docker 容器中运行我的项目,然后尝试通过 laragon 访问它,我遇到了类似的问题,这是由于/bootstrap/cache/config.php.

I fixed fit by running php artisan config:clear, this deletes the /bootstrap/cache/config.phpfile automatically.

我通过运行修复了适合php artisan config:clear,这会/bootstrap/cache/config.php自动删除文件。

回答by jeremykenedy

You may need to clear the autoloader with composer dump-autoload

您可能需要使用以下命令清除自动装载机 composer dump-autoload

If that doesn't work you can manually remove the following non-tracked (usually) files to clear the autoloader and cache if they get jammed up:

如果这不起作用,您可以手动删除以下非跟踪(通常)文件以清除自动加载器和缓存(如果它们被卡住):

/bootstrap/cache/packages.php

/bootstrap/cache/packages.php

/bootstrap/cache/services.php

/bootstrap/cache/services.php

回答by Martin Adiputra

maybe you need to chmod 777 -R storage folder. and i think it can also chown www-data:www-data

也许您需要 chmod 777 -R 存储文件夹。我认为它也可以 chown www-data:www-data