按照文档:https://github.com/fecshop/yii2_fecshop_docker
进行安装,连接redis报错,如下:
Database Exception – yii\db\Exception
Failed to open redis DB connection (127.0.0.1:6379, database=6): 111 - Connection refused
Error Info: Connection refused
1. in /www/web/fecshop/vendor/yiisoft/yii2-redis/src/Connection.php at line 565
556557558559560561562563564565566567568569570571572573574
$this->executeCommand('AUTH', [$this->password]);
}
if ($this->database !== null) {
$this->executeCommand('SELECT', [$this->database]);
}
$this->initConnection();
} else {
\Yii::error("Failed to open redis DB connection ($connection): $errorNumber - $errorDescription", __CLASS__);
$message = YII_DEBUG ? "Failed to open redis DB connection ($connection): $errorNumber - $errorDescription" : 'Failed to open DB connection.';
throw new Exception($message, $errorDescription, $errorNumber);
}
}
/**
* Closes the currently active DB connection.
* It does nothing if the connection is already closed.
*/
public function close()
{
2. in /www/web/fecshop/vendor/yiisoft/yii2-redis/src/Connection.php at line 665 – yii\redis\Connection::open()
659660661662663664665666667668669670671
* See [redis protocol description](http://redis.io/topics/protocol)
* for details on the mentioned reply types.
* @throws Exception for commands that return [error reply](http://redis.io/topics/protocol#error-reply).
*/
public function executeCommand($name, $params = [])
{
$this->open();
$params = array_merge(explode(' ', $name), $params);
$command = '*' . count($params) . "\r\n";
foreach ($params as $arg) {
$command .= '$' . mb_strlen($arg, '8bit') . "\r\n" . $arg . "\r\n";
}
3. in /www/web/fecshop/vendor/yiisoft/yii2-redis/src/Cache.php at line 154 – yii\redis\Connection::executeCommand('GET', ['appfront_cache014d202e6bb52ec256...'])
148149150151152153154155156157158159160
/**
* @inheritdoc
*/
protected function getValue($key)
{
return $this->getReplica()->executeCommand('GET', [$key]);
}
/**
* @inheritdoc
*/
protected function getValues($keys)
4. in /www/web/fecshop/vendor/yiisoft/yii2/caching/Cache.php at line 114 – yii\redis\Cache::getValue('appfront_cache014d202e6bb52ec256...')
5. in /www/web/fecshop/vendor/yiisoft/yii2/web/UrlManager.php at line 296 – yii\caching\Cache::get('appfront_cache014d202e6bb52ec256...')
6. in /www/web/fecshop/vendor/yiisoft/yii2/web/UrlManager.php at line 229 – yii\web\UrlManager::getBuiltRulesFromCache(['' => 'cms/home/index'])
7. in /www/web/fecshop/vendor/yiisoft/yii2/web/UrlManager.php at line 191 – yii\web\UrlManager::buildRules(['' => 'cms/home/index'])
8. in /www/web/fecshop/vendor/yiisoft/yii2/base/BaseObject.php at line 109 – yii\web\UrlManager::init()
9. yii\base\BaseObject::__construct(['enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['' => 'cms/home/index']])
10. in /www/web/fecshop/vendor/yiisoft/yii2/di/Container.php at line 383 – ReflectionClass::newInstanceArgs([['enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['' => 'cms/home/index']]])
11. in /www/web/fecshop/vendor/yiisoft/yii2/di/Container.php at line 156 – yii\di\Container::build('yii\web\UrlManager', [], ['enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['' => 'cms/home/index']])
12. in /www/web/fecshop/vendor/yiisoft/yii2/BaseYii.php at line 349 – yii\di\Container::get('yii\web\UrlManager', [], ['enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['' => 'cms/home/index']])
13. in /www/web/fecshop/vendor/yiisoft/yii2/di/ServiceLocator.php at line 137 – yii\BaseYii::createObject(['enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['' => 'cms/home/index']])
14. in /www/web/fecshop/vendor/yiisoft/yii2/base/Module.php at line 742 – yii\di\ServiceLocator::get('urlManager', true)
15. in /www/web/fecshop/vendor/yiisoft/yii2/base/Application.php at line 571 – yii\base\Module::get('urlManager')
16. in /www/web/fecshop/vendor/yiisoft/yii2-debug/Module.php at line 197 – yii\base\Application::getUrlManager()
191192193194195196197198199200201202203
// delay attaching event handler to the view component after it is fully configured
$app->on(Application::EVENT_BEFORE_REQUEST, function () use ($app) {
$app->getView()->on(View::EVENT_END_BODY, [$this, 'renderToolbar']);
$app->getResponse()->on(Response::EVENT_AFTER_PREPARE, [$this, 'setDebugHeaders']);
});
$app->getUrlManager()->addRules([
[
'class' => 'yii\web\UrlRule',
'route' => $this->id,
'pattern' => $this->id,
],
[
17. in /www/web/fecshop/vendor/yiisoft/yii2/base/Application.php at line 327 – yii\debug\Module::bootstrap(yii\web\Application)
18. in /www/web/fecshop/vendor/yiisoft/yii2/web/Application.php at line 69 – yii\base\Application::bootstrap()
19. in /www/web/fecshop/vendor/yiisoft/yii2/base/Application.php at line 273 – yii\web\Application::bootstrap()
20. in /www/web/fecshop/vendor/yiisoft/yii2/base/BaseObject.php at line 109 – yii\base\Application::init()
21. in /www/web/fecshop/vendor/yiisoft/yii2/base/Application.php at line 206 – yii\base\BaseObject::__construct(['components' => ['urlManager' => ['class' => 'yii\web\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['' => 'cms/home/index']], 'assetManager' => ['forceCopy' => false, 'class' => 'yii\web\AssetManager'], 'db' => ['class' => 'yii\db\Connection', 'dsn' => 'mysql:host=127.0.0.1;dbname=fecs...', 'username' => 'root', 'password' => 'di190478A', ...], 'mongodb' => ['class' => 'yii\mongodb\Connection', 'dsn' => 'mongodb://127.0.0.1:27017/fecsho...'], ...], 'id' => 'app-front', 'controllerNamespace' => 'appfront\controllers', 'params' => ['appfrontBaseTheme' => '@fecshop/app/appfront/theme/base...', 'appfrontBaseLayoutName' => 'main.php', 'appName' => 'appfront'], ...])
22. in /www/web/fecshop/appfront/web/index.php at line 89 – yii\base\Application::__construct(['components' => ['urlManager' => ['class' => 'yii\web\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ['' => 'cms/home/index']], 'assetManager' => ['forceCopy' => false, 'class' => 'yii\web\AssetManager'], 'db' => ['class' => 'yii\db\Connection', 'dsn' => 'mysql:host=127.0.0.1;dbname=fecs...', 'username' => 'root', 'password' => 'di190478A', ...], 'mongodb' => ['class' => 'yii\mongodb\Connection', 'dsn' => 'mongodb://127.0.0.1:27017/fecsho...'], ...], 'id' => 'app-front', 'controllerNamespace' => 'appfront\controllers', 'params' => ['appfrontBaseTheme' => '@fecshop/app/appfront/theme/base...', 'appfrontBaseLayoutName' => 'main.php', 'appName' => 'appfront'], ...])
8384858687888990
* 使用方法:Yii::$service->cms->article;
* 上面的例子就是获取cms服务的子服务article。
*/
new fecshop\services\Application($config['services']);
unset($config['services']);
$application = new yii\web\Application($config);
$application->run();