I have installed Magento2 on my localhost. But it doesn't load the CSS and JS files. Admin interface is as below. Frontend also have the same issue. I set the file permissions. How to fix this?
5 Answers
Deleting the pub/static
folder should work.
But also try php bin/magento setup:static-content:deploy
or php bin/magento setup:upgrade
from the root folder
See CSS and Javascript files are not loading after Magento 2 installation
Looks like UrlRewrite module is disabled in Apache configuration. Please try solution from Magento Documentation
Allow the loading of htaccess files and usage of rewrite rules.I have same problem occur, Enabling rewrite_module
of apache works for me.
Or try to delete the pub/static
folder.
Look into
\app\etc\di.xml and find the
virtualType name="developerMaterialization" .
In this you'll find an item name="view_preprocessed" and change its content
from
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink
to
Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
then delete the files under pub/static except .htaccess file and reload the site.
It should work for you.
If you are facing problem of css and js page load design after installation in magento2
please follow the following step-:
open the terminal and navigate to magento web root
$ cd /var/www/html/magento2
Step 1.
$ php bin/magento setup:static-content:deploy
Step 2.
$ php bin/magento indexer:reindex
Step 3.
make sure apache "rewrite_module" is enable and then restart the server
Step 4.
$ chown -R www-data:www-data /var/www/html/magento2
Step 5.
$ chmod -R 777 /var/www/html/magento2
Step 6.
delete cache folder under var/cache
The above step working. I hope this will work for you also.