Laravel Cache 不在生产服务器上存储缓存文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26383630/
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
Laravel Cache does not store cache file on production server
提问by KeizerBridge
I have a problem with the Laravel Cache system (I use Laravel 4.1).
我的 Laravel 缓存系统有问题(我使用Laravel 4.1)。
- On my local server, the "app/storage" folder where Laravel store cache's files is with 755permission.
- On my production server, the same folderhas the same permissioncode.
- On my local server, when I cache datas using the Laravel's Cache Class, it works. So If I go within the "app/storage" folder, I can see the files created.
- On my production server, it doesn't.. Files aren't createdin
the cache folder within "app/storage" whereas session and views
folders (present in app/storage) has files stored. I can confirm it
cause it always go inside my if statement using
has
method even if I put my$datas
using theput
method of Cache Class.
- 在我的本地服务器上,Laravel 存储缓存文件的“ app/storage”文件夹具有755权限。
- 在我的生产服务器上,同一个文件夹具有相同的权限代码。
- 在我的本地服务器上,当我使用 Laravel 的缓存类缓存数据时,它可以工作。所以如果我进入“ app/storage”文件夹,我可以看到创建的文件。
- 在我的生产服务器上,它没有......文件不是在“ app/storage”中的缓存文件夹中创建的,而 session 和 views 文件夹(存在于 app/storage 中)存储了文件。我可以确认它因为它总是在我的 if 语句中使用
has
方法,即使我$datas
使用put
缓存类的方法也是如此。
EDIT
编辑
/*
|--------------------------------------------------------------------------
| Default Cache Driver
|--------------------------------------------------------------------------
|
| This option controls the default cache "driver" that will be used when
| using the Caching library. Of course, you may use other drivers any
| time you wish. This is the default when another is not specified.
|
| Supported: "file", "database", "apc", "memcached", "redis", "array"
|
*/
'driver' => 'file',
/*
|--------------------------------------------------------------------------
| File Cache Location
|--------------------------------------------------------------------------
|
| When using the "file" cache driver, we need a location where the cache
| files may be stored. A sensible default has been specified, but you
| are free to change it to any other place on disk that you desire.
|
*/
'path' => storage_path(). DIRECTORY_SEPARATOR . 'cache',
/*
|--------------------------------------------------------------------------
| Database Cache Connection
|--------------------------------------------------------------------------
|
| When using the "database" cache driver you may specify the connection
| that should be used to store the cached items. When this option is
| null the default database connection will be utilized for cache.
|
*/
'connection' => null,
/*
|--------------------------------------------------------------------------
| Database Cache Table
|--------------------------------------------------------------------------
|
| When using the "database" cache driver we need to know the table that
| should be used to store the cached items. A default table name has
| been provided but you're free to change it however you deem fit.
|
*/
'table' => 'cache',
/*
|--------------------------------------------------------------------------
| Memcached Servers
|--------------------------------------------------------------------------
|
| Now you may specify an array of your Memcached servers that should be
| used when utilizing the Memcached cache driver. All of the servers
| should contain a value for "host", "port", and "weight" options.
|
*/
'memcached' => array(
array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
),
/*
|--------------------------------------------------------------------------
| 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',
Do you have any idea about what I'm doing wrong ?
你知道我做错了什么吗?
回答by P??
Set the permissions for the folder from 755 to 777 to see if it works. If the cache works now, then you have a permission problem. Set it back to 755 and make sure the user your web server uses is the owner of your folder.
将文件夹的权限从 755 设置为 777 以查看它是否有效。如果缓存现在工作,那么你有权限问题。将其设置回 755 并确保您的 Web 服务器使用的用户是您的文件夹的所有者。