2017-06-02 109 views
0

從phpinfo()函數: phpinfo, memcache is loaded錯誤消息:「MemCache需要加載PHP memcache擴展。」遷移後。

然而,當我嘗試遷移,顯示此錯誤:

Exception 'yii\base\InvalidConfigException' with message 'MemCache requires PHP memcache extension to be loaded.' 

in /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/caching/MemCache.php:217 

Stack trace: 
#0 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/caching/MemCache.php(113): yii\caching\MemCache->getMemcache() 
#1 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/Object.php(107): yii\caching\MemCache->init() 
#2 [internal function]: yii\base\Object->__construct(Array) 
#3 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/di/Container.php(372): ReflectionClass->newInstanceArgs(Array) 
#4 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/di/Container.php(151): yii\di\Container->build('yii\\caching\\Mem...', Array, Array) 
#5 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/BaseYii.php(344): yii\di\Container->get('yii\\caching\\Mem...', Array, Array) 
#6 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/di/ServiceLocator.php(133): yii\BaseYii::createObject(Array) 
#7 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/db/Schema.php(275): yii\di\ServiceLocator->get('cache', false) 
#8 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/db/Migration.php(71): yii\db\Schema->refresh() 
#9 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/Object.php(107): yii\db\Migration->init() 
#10 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/controllers/MigrateController.php(113): yii\base\Object->__construct(Array) 
#11 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(491): yii\console\controllers\MigrateController->createMigration('m170316_221710_...') 
#12 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(129): yii\console\controllers\BaseMigrateController->migrateUp('m170316_221710_...') 
#13 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0) 
#14 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array) 
#15 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array) 
#16 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/Controller.php(91): yii\base\Controller->runAction('', Array) 
#17 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/Module.php(455): yii\console\Controller->runAction('', Array) 
#18 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/Application.php(167): yii\base\Module->runAction('migrate', Array) 
#19 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/console/Application.php(143): yii\console\Application->runAction('migrate', Array) 
#20 /Library/WebServer/Documents/r2d2/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request)) 
#21 /Library/WebServer/Documents/r2d2/yii(27): yii\base\Application->run() 
#22 {main} 

有人能幫助我找出原因?

謝謝!

+0

....也許嘗試安裝memcache擴展? – Farkie

回答

0

錯誤來自控制檯應用程序,phpinfo輸出來自web服務器。所以,你基本上啓用了web服務器的memcache模塊,但沒有用於控制檯。爲了給出確切的解決方案,需要更多有關您的設置的信息:您使用什麼,php-fpm,modapache?請提供完整的phpinfo輸出無論是從網絡和CLI

UPDATE

檢查哪些目錄額外的ini文件控制檯PHP掃描:

php -i | grep "Scan this dir for additional .ini files" 

然後你需要把配置文件(例如memcache.ini)並將模塊配置爲其中之一。內容應該是這樣的:

extension=memcache.so 

您可以檢查一個網絡服務器用作參考。

+0

我已經在控制檯中嘗試過'php -i',它不顯示啓用了內存緩存。你能告訴我如何啓用控制檯模塊? –

+0

更新了我的回答 –

+0

奇怪的是遷移在我的另一個yii2網站在同一臺計算機上正常工作,但出現錯誤'異常'yii \ base \ InvalidConfigException'消息'MemCache需要PHP memcache擴展才能加載。 '這個錯誤。有沒有我應該注意的任何不正確的配置?謝謝! –