【问题标题】:Magento 2 - 500 Internal Server Error after migrating to different folderMagento 2 - 迁移到不同文件夹后出现 500 内部服务器错误
【发布时间】:2020-05-22 22:10:10
【问题描述】:

我正在开发一个 Magento 2 网站,我制作了该网站的副本,以便将其复制到同一台服务器上的不同文件夹中以用于登台/生产环境。

我执行了以下操作:

  • 已复制所有文件和文件夹
  • 复制了数据库
  • 已将所有文件复制到新文件夹
  • 已创建新数据库
  • 导入的数据库副本但 URL 已更改
  • 更新配置以指向新数据库
  • 删除了 var、vendor 和 pub 静态内容
  • 运行以下命令:

- composer install

- php bin/magento setup:upgrade

- php bin/magento setup:di:compile

- php bin/magento setup:static-content:Deploy -f

- chmod -R 777 var/ generated/ pub/static

- php bin/magento cache:clean

- php bin/magento cache:flush

- bin/magento indexer:reindex


我还启用了错误和开发者模式。当我访问主页时,我收到 500 内部服务器错误,但没有可见错误。

管理面板和子页面似乎工作正常,但主页出现空白屏幕/500 错误。

我在服务器日志中看到以下错误:


[23-May-2020 07:54:49 UTC] PHP Fatal error:  Uncaught Error: Call to a member function addAttributeToFilter() on null in /var/www/vhosts/websitename/htdocs/app/code/Sm/FilterProducts/Block/FilterProducts.php:276
Stack trace:
#0 /var/www/vhosts/websitename/htdocs/app/code/Sm/FilterProducts/Block/FilterProducts.php(201): Sm\FilterProducts\Block\FilterProducts->_featuredProducts()
#1 /var/www/vhosts/websitename/htdocs/app/code/Sm/FilterProducts/Block/FilterProducts.php(496): Sm\FilterProducts\Block\FilterProducts->_getProducts()
#2 /var/www/vhosts/websitename/htdocs/generated/code/Sm/FilterProducts/Block/FilterProducts/Interceptor.php(102): Sm\FilterProducts\Block\FilterProducts->getLoadedProductCollection()
#3 /var/www/vhosts/websitename/htdocs/app/design/frontend/Sm/shiny/Sm_FilterProducts/templates/default-grid.phtml(15): Sm\FilterProducts\Block\FilterProducts\Interceptor->getLoadedProductCollection()
#4 /var/www/vhosts/websitename/htdocs/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/ww in /var/www/vhosts/websitename/htdocs/app/code/Sm/FilterProducts/Block/FilterProducts.php on line 276


当我查看 magento 调试日志时,我看到以下错误:

[2020-05-22 22:01:55] main.INFO: Broken reference: the 'wishlist_sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'yotpo_bottomline' element cannot be added as child to 'product.info.main', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'banner-sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'footer_blog_link' element cannot be added as child to 'footer_links', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'paypal.partner.right.logo' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'bml.right.logo' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'yotpo_bottomline' tries to reorder itself towards 'product.info.addto', but their parents are different: 'product.info.main' and '' respectively. [] []


我花了一天的大部分时间来解决这个问题。

非常感谢任何人都可以提供的任何指导。

【问题讨论】:

  • 您的command 运行成功了吗?
  • 尝试找出您的 Web 服务器错误日志的位置会很有帮助。看起来您正在查看 magento 日志,但 500 错误的详细信息将显示在 Web 服务器(例如 apache)日志中
  • 是的,所有命令都运行良好。 @mozboz 我已使用服务器日志中的日志更新了问题。我已进一步查看报告的错误,但无法解决。

标签: php magento2 internal-server-error


【解决方案1】:

我从 app 目录重新复制了文件,它解决了这个问题。我想我可能错过了一些课程。

【讨论】:

    【解决方案2】:

    我不了解 magento,但根据使用 Wordpress 和其他大型 PHP 应用程序的经验,我倾向于先执行这些步骤,然后看看会发生什么。您可能会发现您正在执行的 magento 命令行操作以某种方式与您的配置或数据发生了冲突——在安装开始之前不要运行它们。

    所以,请尝试重新开始,但只执行以下步骤:

    • 将文件复制到新位置
    • 将数据库复制到新数据库
    • 抽查所有到达的文件,包括 .文件(如 .htaccess)
    • 抽查新数据库是否在您期望的位置
    • 更新数据库配置
    • 仅为 URL 更改、路径和数据库设置更新 Magento 配置。不要更改任何其他内容!
    • 测试看看会发生什么

    可能有一些 magento 特定的东西可以清除缓存或其他东西,如果在你开始这个过程之前有可能做到这一点,而不会弄乱你的 prod 环境,请尝试这样做。

    【讨论】:

      【解决方案3】:

      我不了解 magento,但根据使用 Wordpress 和其他大型 PHP 应用程序的经验,我倾向于先执行这些步骤,然后看看会发生什么。您绝对不想在将它移动到新位置的同时执行多个步骤,例如升级 magento。您可能会发现您正在执行的 magento 命令行操作以某种方式与您的配置或数据发生了冲突——在安装开始之前不要运行它们。

      所以,请尝试重新开始,但只执行以下步骤:

      • 将文件复制到新位置
      • 将数据库复制到新数据库
      • 抽查所有到达的文件,包括 .文件(如 .htaccess)
      • 抽查新数据库是否在您期望的位置
      • 仅为 URL 更改、路径和数据库设置更新 Magento 配置。不要更改任何其他内容!
      • 测试看看会发生什么

      可能有一些 magento 特定的东西可以清除缓存或其他东西,如果在你开始这个过程之前有可能做到这一点,而不会弄乱你的 prod 环境,请尝试这样做。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-02-05
        • 1970-01-01
        • 2011-10-20
        • 1970-01-01
        • 2015-10-08
        • 2015-09-06
        • 2019-07-19
        • 1970-01-01
        相关资源
        最近更新 更多