Jon*_*nis 15 php caching laravel-5
我在渲染任何页面时从Laravel5收到以下错误:
ErrorException in Filesystem.php line 74:
file_put_contents(/fdcc73e2e72031a510ae8f921ce1d22d): failed to open stream: Permission denied
Run Code Online (Sandbox Code Playgroud)
我的缓存配置如下:
<?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',
];
Run Code Online (Sandbox Code Playgroud)
有趣的是,如果我将默认值更改为数组或任何其他选项,它仍会尝试将缓存文件写入根文件夹并且每次都失败.
有人遇到过这种情况么?
ser*_*sun 20
看看是否存在'storage/framework/views'.如果你添加它仍然有问题.确保它是可写的(775,77等......)
在我的情况下,错误发生是因为我通过github部署到我的生产服务器,但存储的内容没有被git跟踪.我通过确保/ storage中的每个目录中的.gitignore文件都已提交到repo来修复此问题.
注意: 通常这些奇怪的文件名与Blade模板有关.我不认为它实际上是在尝试将缓存文件存储在root中.
我的错误类似:"Filesystem.php第81行中的ErrorException:file_put_contents(/ f946048111f1176619e22f5127724e37):无法打开流:权限被拒绝"
小智 9
我正在使用debian 7 wheezy.
如果您遇到这些类型的错误,请执行以下步骤
转到app文件夹(例如:/ home/app/web)
注意:此处的Webuser是指www-data或自定义用户
请确保数据库已与页面连接.
您从哪里加载CACHE_DRIVER?
线路
'default' => env('CACHE_DRIVER', 'file'),
正在查找您的系统环境变量和位于项目根目录的.env文件。根据您所描述的,我假设您只是尝试更改缓存配置文件中的缓存方法。该方法的第二个参数是“默认”值,以防 Laravel 在其他地方找不到CACHE_DRIVER。
您应该检查项目根目录下的文件.env中的变量CACHE_DRIVER。如果存在,该值将优先于cache.php.
另一个解决方案是确保 laravel 对指定目录具有写入权限。查看该文件夹是否具有用户或组的写入权限www-data(至少)。
| 归档时间: |
|
| 查看次数: |
4420 次 |
| 最近记录: |