文档 下载安装 商店 博客 问答 主机

magento2.2迁移到服务器失败

magento2

#1

开发环境没有问题,迁移到服务器,改了数据库域名这些都不行,访问首页报错,让看错误日志,错误日志如下
[2018-01-20 07:03:54] main.CRITICAL: No such entity. {“exception”:"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): No such entity. at /home/magento/vendor/magento/module-store/Model/WebsiteRepository.php:102)"} []
[2018-01-20 07:46:54] main.CRITICAL: No such entity. {“exception”:"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): No such entity. at /home/magento/vendor/magento/module-store/Model/WebsiteRepository.php:104)"} []
[2018-01-20 07:54:53] main.CRITICAL: No such entity. {“exception”:"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): No such entity. at /home/magento/vendor/magento/module-store/Model/WebsiteRepository.php:104)"} []
[2018-01-20 08:25:25] main.CRITICAL: No such entity. {“exception”:"[object] (Magento\Framework\Exception\NoSuchEntityException(code: 0): No such entity. at /home/magento/vendor/magento/module-store/Model/WebsiteRepository.php:104)"} []

开发环境
Apache/2.2.31 (Unix) mod_wsgi/3.5 Python/2.7.13 PHP/7.0.15 mod_ssl/2.2.31 OpenSSL/1.0.2j DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0
mysqlnd 5.0.12

服务器
Apache/2.4.6 (CentOS)
PHP/7.0.25
mysql 5.6.35


#2

完整错误日志
Magento\Framework\Exception\NoSuchEntityException: No such entity. in /home/magento/vendor/magento/module-store/Model/WebsiteRepository.php:102 Stack trace: #0 /home/magento/vendor/magento/module-store/Model/StoreManager.php(204): Magento\Store\Model\WebsiteRepository->getById(‘0’) #1 /home/magento/generated/code/Magento/Store/Model/StoreManagerInterface/Proxy.php(135): Magento\Store\Model\StoreManager->getWebsite(‘0’) #2 /home/magento/vendor/magento/module-store/Model/Resolver/Website.php(30): Magento\Store\Model\StoreManagerInterface\Proxy->getWebsite(‘0’) #3 /home/magento/vendor/magento/framework/App/Config/ScopeCodeResolver.php(49): Magento\Store\Model\Resolver\Website->getScope(‘0’) #4 /home/magento/vendor/magento/module-config/App/Config/Source/RuntimeConfigSource.php(86): Magento\Framework\App\Config\ScopeCodeResolver->resolve(‘website’, ‘0’) #5 /home/magento/vendor/magento/module-config/App/Config/Source/RuntimeConfigSource.php(62): Magento\Config\App\Config\Source\RuntimeConfigSource->loadConfig() #6 /home/magento/vendor/magento/framework/App/Config/ConfigSourceAggregated.php(40): Magento\Config\App\Config\Source\RuntimeConfigSource->get(’’) #7 /home/magento/vendor/magento/module-config/App/Config/Type/System/Reader.php(60): Magento\Framework\App\Config\ConfigSourceAggregated->get() #8 /home/magento/generated/code/Magento/Config/App/Config/Type/System/Reader/Proxy.php(95): Magento\Config\App\Config\Type\System\Reader->read() #9 /home/magento/vendor/magento/module-config/App/Config/Type/System.php(292): Magento\Config\App\Config\Type\System\Reader\Proxy->read() #10 /home/magento/vendor/magento/module-config/App/Config/Type/System.php(191): Magento\Config\App\Config\Type\System->readData() #11 /home/magento/vendor/magento/module-config/App/Config/Type/System.php(152): Magento\Config\App\Config\Type\System->loadDefaultScopeData(‘default’) #12 /home/magento/vendor/magento/framework/App/Config.php(131): Magento\Config\App\Config\Type\System->get(‘default/newreli…’) #13 /home/magento/vendor/magento/framework/App/Config.php(80): Magento\Framework\App\Config->get(‘system’, ‘default/newreli…’) #14 /home/magento/vendor/magento/module-new-relic-reporting/Model/Config.php(91): Magento\Framework\App\Config->getValue(‘newrelicreporti…’) #15 /home/magento/vendor/magento/module-new-relic-reporting/Plugin/HttpPlugin.php(49): Magento\NewRelicReporting\Model\Config->isNewRelicEnabled() #16 /home/magento/vendor/magento/framework/Interception/Interceptor.php(121): Magento\NewRelicReporting\Plugin\HttpPlugin->beforeCatchException(Object(Magento\Framework\App\Http\Interceptor), Object(Magento\Framework\App\Bootstrap), Object(Magento\Framework\Exception\NoSuchEntityException)) #17 /home/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Bootstrap), Object(Magento\Framework\Exception\NoSuchEntityException)) #18 /home/magento/generated/code/Magento/Framework/App/Http/Interceptor.php(39): Magento\Framework\App\Http\Interceptor->___callPlugins(‘catchException’, Array, Array) #19 /home/magento/vendor/magento/framework/App/Bootstrap.php(261): Magento\Framework\App\Http\Interceptor->catchException(Object(Magento\Framework\App\Bootstrap), Object(Magento\Framework\Exception\NoSuchEntityException)) #20 /home/magento/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor)) #21 {main}


#3

你说首页报错,麻烦先把首页截图发一份。


#4

哥哥,上面就是首页的报错


#5


#6

运行一个bin/magento setup:up 命令试试


#7


#8

有点莫名其妙哈,谢谢大神搭救


#9

试试SQL运行一下:

SET FOREIGN_KEY_CHECKS=0;
UPDATE `store` SET store_id = 0 WHERE code='admin';
UPDATE `store_group` SET group_id = 0 WHERE name='Default';
UPDATE `store_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;

#10

多谢大神,执行完sql后就可以了,请问这是什么原因,我本地测试环境链接的是同一个数据库,执行sql前可以用,执行完sql还是可以用,本地完全不收影响


#11

可能是在迁移时导入数据库的时候,发生了外键约束。
用了这个命令之后就修复了。