简体   繁体   中英

Blank admin page after installing Magento 2.3 on Windows 10

I am installing Magento 2.3 locally on Windows 10 with xampp. I downloaded the archive from Github, unzipped to c:\\xampp\\htdocs\\magento2 , and ran the installer from localhost/magento2/setup in my browser.

The installer finished with no errors, however when I go to the admin page, I get a blank page with a grayish background. When I go to localhost/magento2 , I get this

我明白了

When I look in magento2/var/log/system.log , there are some errors that say stuff like the following (each of these errors is repeated several times for a list of different file names)

main.ERROR: A symlink for "C:/xampp/htdocs/magento2/lib/web/requirejs/require.js" can't be created and placed to "C:/xampp/htdocs/magento2/pub/static/adminhtml/Magento/backend/en_US/requirejs/require.js". Warning!symlink(): Cannot create symlink, error code(1314) [] [] ) [] []

main.CRITICAL: Invalid template file: 'C:/xampp/htdocs/magento2/app/code/Magento/Backend/view/adminhtml/templates/page/js/require_js.phtml' in module: 'Magento_Backend' block's name: 'require.js' [] []

EDIT:

I got the admin page working by changing the code in magento\\lib\\internal\\Magento\\Framework\\View\\Element\\Template\\File\\Validator.php

The original code was

public function isValid($filename)
{
    $filename = str_replace('\\', '/', $filename);
    if (!isset($this->_templatesValidationResults[$filename])) {
        $this->_templatesValidationResults[$filename] =
            ($this->isPathInDirectories($filename, $this->_compiledDir)
                || $this->isPathInDirectories($filename, $this->moduleDirs)
                || $this->isPathInDirectories($filename, $this->_themesDir)
                || $this->_isAllowSymlinks)
            && $this->getRootDirectory()->isFile($this->getRootDirectory()->getRelativePath($filename));
    }
    return $this->_templatesValidationResults[$filename];
}

I changed it to

public function isValid($filename)
{
   return true;
}

Since I'm new to Magento, I don't understand what this method is supposed to be doing (I assume it's validating a template file, but I don't know how or where). Furthermore, when I added a log statement to the original code to show the contents of $this->_templatesValidationResults[$filename] (right before the return statement), it printed several empty array elements. For example, it printed

[] []  
[] []
[] []
[] []

It appears like Magento thinks the template files are invalid, but it doesn't give any reasons why they're invalid. Am I correct in saying this, and how would I either stop Magento from erroneously detecting the template files as invalid, or get the proper validation error message?

Possible Solution, and Further Questions

I traced the problem to the file magento\\lib\\internal\\Magento\\Framework\\View\\Element\\Template\\File\\Validator.php

at the function

protected function isPathInDirectories($path, $directories)
{
    if (!is_array($directories)) {
        $directories = (array)$directories;
    }
    $realPath = $this->fileDriver->getRealPath($path);
    foreach ($directories as $directory) {
        if (0 === strpos($realPath, $directory)) {
            return true;
        }
    }
    return false;
}

The problem is that $path has forward slashes in it, but $realPath has backslashes, so the strpos never returns a match, and the function always returns false. I updated the function to

protected function isPathInDirectories($path, $directories)
{
    if (!is_array($directories)) {
        $directories = (array)$directories;
    }
    $realPath = $this->fileDriver->getRealPath($path);
    foreach ($directories as $directory) {
        if (0 === strpos($realPath, $directory) || 0 === strpos($path, $directory)) {
            return true;
        }
    }
    return false;
}

And now it works. I assume this is a Windows-only problem? Is this a bug in Magento that doesn't account for Windows file naming, or is there something I've done incorrectly in my setup?

I have same issue to with magento 2.3 on Windows 10, backoffice page show blank page with brown background.

after searching the problem on the web, finally found solution

  1. open file /vendor/magento/framework/View/Element/Template/File/Validator.php in magento install dir , find

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

replace with :

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

Finally login page showing, but the icon is missing in login page and after login

  1. open file app/etc/di.xml in magento install dir, find

    Magento\\Framework\\App\\View\\Asset\\MaterializationStrategy\\Symlink

and replace with

Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
  1. Then go to var/cache , delete all folder / file
  2. refresh the page, done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM