Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blank admin page on Magento 2.3.0 CE in localhost

I have installed Magento 2.3 on my local-machine, installation goes fine. I can access my store at localhost/magento. I tried to access my admin page localhost/magento/admin_pogi but it gives me a blank page and redirected to the url http://localhost/magento/admin_pogi/admin/index/index/key/a062e79f617010c42b07d662103d5142cd9bbe86314fb54da3e4cb5542b11eee/.

What I have tried so far is to enable development mode, and I see this error on my admin page:

1 exception(s):
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid 
template file: 'C:/xampp/htdocs/magento/vendor/magento/module- backend/view/adminhtml/templates/page/js/require_js.phtml' in module: 
'Magento_Backend' block's name: 'require.js'

Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'C:/xampp/htdocs/magento/vendor/magento/module-backend/view/adminhtml/templates/page/js/require_js.phtml' in module: 'Magento_Backend' block's name: 'require.js'
#0 C:\xampp\htdocs\magento\vendor\magento\framework\View\Element\Template.php(301): 
Magento\Framework\View\Element\Template->fetchView('C:/xampp/htdocs...')
#1 C:\xampp\htdocs\magento\vendor\magento\framework\View\Element\AbstractBlock.php(668): Magento\Framework\View\Element\Template->_toHtml()#2 
C:\xampp\htdocs\magento\vendor\magento\framework\View\Result\Page.php(249): 
Magento\Framework\View\Element\AbstractBlock->toHtml()
#3 
C:\xampp\htdocs\magento\vendor\magento\framework\View\Result\Layout.php(171): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
#4 C:\xampp\htdocs\magento\generated\code\Magento\Backend\Model\View\Result\Page\Interceptor.php(193): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#5 C:\xampp\htdocs\magento\vendor\magento\framework\App\Http.php(139): Magento\Backend\Model\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#6 C:\xampp\htdocs\magento\generated\code\Magento\Framework\App\Http\Interceptor.php(24): Magento\Framework\App\Http->launch()
#7 C:\xampp\htdocs\magento\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http\Interceptor->launch()
#8 C:\xampp\htdocs\magento\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#9 {main}
like image 903
user8143979 Avatar asked Nov 30 '18 05:11

user8143979


People also ask

Where is admin URL Magento 2?

Typically, the default Magento 2 admin URL is “yourdomain.com/magento/admin.”

Where is the admin panel in Magento?

When you log into your Magento 2 Admin area, you will find yourself in the Admin Dashboard - the default startup page for store owners and their staff. Here, you can see all the info about your lifetime sales, average order value, last orders and search terms. At the main part of the workspace, you'll find a chart.

What is the full URL to the Magento login page?

Default Base URL: http://yourdomain.com/magento/ Default Admin URL and Path: http://yourdomain.com/magento/admin.


2 Answers

This would be a bug that addresses this commit. Author changed $path to

$this->fileDriver->getRealPath($path)

which is simply calling realpath() on $path but that might change directory separators on the $path that previously were affected by

#/vendor/magento/framework/View/Element/Template/File/Validator.php:114
$filename = str_replace('\\', '/', $filename);

On a Windows OS this will revert changes of above str_replace so that a path like

D:/Magento2.3/vendor/magento

will be canonicalized to its Windows specific version:

D:\Magento2.3\vendor\magento

and this will not result in a successful comparison within isPathInDirectories() method of Magento\Framework\View\Element\Template\File\Validator class:

foreach ($directories as $directory) {
    if (0 === strpos($realPath, $directory)) {
        return true;
    }
}

Solution

Currently we can go for a dirty quick change in the above foreach loop so that we can run our magento with no further problems on this:

#/vendor/magento/framework/View/Element/Template/File/Validator.php:139
foreach ($directories as $directory) {
    // Add this line
    $realDirectory = $this->fileDriver->getRealPath($directory);
    // and replace `$directory` with `$realDirectory`
    if (0 === strpos($realPath, $realDirectory)) {
        return true;
    }
}
like image 128
revo Avatar answered Sep 28 '22 12:09

revo


Step 01. Go to this directory C:\xampp\htdocs\magento\vendor\magento\framework\View\Element\Template\File

Step 02. Open file validator.php Comment line 139($realPath = $this->fileDriver->getRealPath($path);) Add this code

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

And also some time admin page load but not load css So how to fix this issue

Step _01 Goto the this directory App/etc/di.xml

step 02 Find this line

<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>

Step 03 change this like below

<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\copy</item>

And also some time the home page not load correctly so how can solve

Step 01 Go to the this directory var/cache

Step 02 Delete cache files and refresh your page

like image 44
pubudu sachintha Avatar answered Sep 28 '22 13:09

pubudu sachintha