javascript magento2安装后黑屏和css js未加载

w80xi6nr  于 2023-02-15  发布在  Java
关注(0)|答案(1)|浏览(125)

在Ubuntu中安装Magento2时,出现了许多问题。通过GitHub克隆Magento2代码
1.运行安装命令后出现黑屏

  1. css和js未加载
    我尝试在conf文件中设置apache2权限
7vux5j2d

7vux5j2d1#

错误-此页无法工作localhost当前无法处理此请求。HTTP错误500解决方案-1.在此函数$realPath = $this->fileDriver->getRealPath($path);下搜索受保护的函数isPathInDirectories($path, $directories),并将其替换为$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
2.将index.php和. htaccess从pub复制到。将index.php中的编辑要求复制到require __DIR__ . '/app/bootstrap.php';
错误-CSS和JS未加载
解决方案-
1.在文件/etc/apache2/apache2.conf中导航〈目录/var/www/〉,将"不允许覆盖"更改为"允许覆盖全部"
1.最后将其添加到位于〈MagentoRootDirectory/app/etc〉的env.php中

'system' => [

       'default' => [

           'web' => [

               'unsecure' => [

                   'base_media_url' => '{{secure_base_url}}pub/media/',

                   'base_static_url' => '{{secure_base_url}}pub/static/'

               ],

               'secure' => [

                   'base_media_url' => '{{secure_base_url}}pub/media/',

                   'base_static_url' => '{{secure_base_url}}pub/static/'

               ]

           ]

       ]

   ]

1.在etc/di.xml中,在"将此Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink修改为Magento\Framework\App\View\Asset\MaterializationStrategy\Copy"下搜索<item name="view_preprocessed" xsi:type="object">
1.将其添加到db INSERT INTO core_config_data (path, value) VALUES ('dev/static/sign', 0) ON DUPLICATE KEY UPDATE value = 0;
1.将其添加到db UPDATE core_config_data SET value = '0' WHERE core_config_data.path LIKE '%web/seo/use_rewrites%';
1.运行此命令,sudo a2enmod重写

相关问题