【发布时间】:2019-12-12 01:53:10
【问题描述】:
如果没有 Redis 运行,我的项目将无法启动。如果我尝试在 Laravel 中没有运行 redis 的情况下打开页面,我会收到此消息:
“由于目标机器主动拒绝,无法建立连接。[tcp://127.0.0.1:6379]”
我试过了 1)php工匠配置:缓存, 2)php工匠清除:缓存, 3)作曲家删除predis/predis 4)作曲家删除predis 5)删除redis实例 6)通过命令行卸载redis
任何帮助将不胜感激!谢谢!
缓存.php
<?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.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/
'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/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'file',
'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' => env(
'CACHE_PREFIX',
str_slug(env('APP_NAME', 'laravel'), '_').'_cache'
),
];
.env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:duZtCSIh12vDNOdmYW2kmMr9ONILxsH55f46npt5/Kg=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forum
DB_USERNAME=
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=bc05914be7f1db
MAIL_PASSWORD=0c73506a138d3f
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
RECAPTCHA_SECRET=
【问题讨论】:
-
您要更换缓存驱动程序吗?
-
不,我不是,我应该改成什么?
-
当我删除 redis 并尝试重新加载页面时 - 它给了我这个错误:找不到 Class 'Predis\Client'
-
只使用文件缓存驱动,它不依赖于文件系统。见laravel.com/docs/5.8/cache
-
谢谢,但我目前正在使用我的 cache.php 文件中的文件缓存驱动程序,但仍然出现相同的错误。