Php Laravel正在尝试将缓存文件存储在根文件夹中
在呈现任何页面时,我从Laravel5收到以下错误:Php Laravel正在尝试将缓存文件存储在根文件夹中,php,caching,laravel-5,Php,Caching,Laravel 5,在呈现任何页面时,我从Laravel5收到以下错误: ErrorException in Filesystem.php line 74: file_put_contents(/fdcc73e2e72031a510ae8f921ce1d22d): failed to open stream: Permission denied 我的缓存配置如下: <?php return [ /* |------------------------------------------
ErrorException in Filesystem.php line 74:
file_put_contents(/fdcc73e2e72031a510ae8f921ce1d22d): failed to open stream: Permission denied
我的缓存配置如下:
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
'apc' => [
'driver' => 'apc'
],
'array' => [
'driver' => 'array'
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path().'/framework/cache',
],
'memcached' => [
'driver' => 'memcached',
'servers' => [
[
'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => 'laravel',
];
从哪里加载缓存驱动程序
线路
'default'=>env('CACHE\u DRIVER','file'),
正在查找系统环境变量和位于项目根目录下的.env文件。在您描述的过程中,我假设您只是试图更改缓存配置文件中的缓存方法。该方法的第二个参数是“默认”值,以防laravel在别处找不到缓存驱动程序
您应该检查项目根目录下的文件.env,以查找变量缓存驱动程序。如果存在,该值将优先于cache.php
中的配置
另一个解决方案是确保laravel在指定的目录中具有写入权限。查看文件夹是否具有写入www-data
用户或组(至少)的权限。查看是否存在“存储/框架/视图”。如果你添加它,你仍然有问题。确保它是可写的(775、77等)
在我的例子中,发生错误是因为我通过github部署到生产服务器,但git没有跟踪存储内容。我通过确保/storage中每个目录中的.gitignore文件都提交到repo来修复此问题
注意事项:
通常这些奇怪的文件名与刀片模板有关。我不认为它实际上是在试图将缓存文件存储在根目录中
我的错误与此类似:“Filesystem.php第81行中的ErrorException:文件内容(/f946048111f1176619e22f5127724e37):无法打开流:权限被拒绝”我正在使用debian 7 wheezy
如果您遇到这些类型的错误,请执行以下步骤
转到应用程序文件夹(例如:/home/app/web)
php artisan配置:缓存
php artisan缓存:清除
php artisan视图:清除
chmod-R 777存储/或chown-R网络用户:网络用户存储/
chmod-R 777 public/or chown-R webuser:webuser public/
重新加载服务apache2,重新启动服务apache2
注:此处的Webuser指的是www数据或自定义用户
请确保数据库与页面连接。我面临类似的问题,你是如何解决的这对我也很有效。我没有通过git发布,但由于某种原因,storage/framework/
目录不存在。创建并设置为775为我修复了它:storage/framework/cache
、storage/framework/sessions
和storage/framework/views
我也有同样的错误,但根本原因是git不存储空目录。因此,我必须创建:/storage/logs
,/storage/framework/cache
,/storage/framework/sessions
,/storage/framework/views
,并将.gitignore文件添加到所有包含这些内容的目录中:#忽略除.gitignore*之外的所有内容!。吉蒂诺谢谢你,先生。我花了一天的时间想弄明白。奇怪的是,如果你做了一件非常错误的事情,给根目录授予权限,它会工作并存储在根目录中!为什么他们不能告诉我们在存储/框架/视图中找不到目录…在OSX上(至少是El Capitan)webuser是www
。