当前位置: 技术文章>> 如何解决安装Magento 2.x后的空白页问题

文章标题:如何解决安装Magento 2.x后的空白页问题
  • 文章分类: Magento
  • 14994 阅读
系统学习magento二次开发,推荐小册:《Magento中文全栈二次开发 》

本小册面向Magento2以上版本,书代码及示例兼容magento2.0-2.4版本。涵盖了magento前端开发,后端开发,magento2主题,magento2重写,magento2 layout,magento2控制器,magento2 block等相关内容,带领您成为magento开发技术专家。


如果您在全新安装Magento 2.x后遇到相同的空白页问题,这是一个解决方案。

要先执行相同的操作,您需要打开位于以下路径的“验证器.php”文件。

vendor\magento\framework\View\Element\Template\File\Validator.php

大约在第 133 行左右,你会发现这个函数。

protected function isPathInDirectories($path, $directories)

现在在这个函数中找到这个代码。

$realPath = $this->fileDriver->getRealPath($path);

并将其替换为以下代码。

$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));

就是这样,现在打开命令行界面 (CLI) 并运行以下命令。

php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f

就是这样。现在导航到管理页面,它将开始工作,您的空白页问题现已解决。


推荐文章