CSS and JS not loading after installation of Magento 2 default template
OS: Windows 10
Xampp Control panel V3.2.2
PHP version: 5.6.28
Server: Apache/2.4.23 (Win32)
phpmyadmin Version information: 4.5.1
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityIts working when i did the following changes:
Remove all files from pub/static
folder but not .htaccess
Go to app/etc/di.xml
Replace ('Symlink' --> 'Copy')
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink
by
Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
Step1 :- Go to var folder and check .htaccess file is available or not. If it is not available then copy .htaccess file in default magento2 and paste.
Step2 :- Go to pub\static folder and check .htaccess file is available or not. If it is not available then copy .htaccess file in default magento2 and paste.
Step3 :- Login your ssh/putty and go to root directory and run below command
a). rm -rf var/*
b). rm -rf pub/static/*
c). php bin/magento setup:static-content:deploy
d). chmod -R 777 var pub/static
Step4 :- Refresh your link.
Here is the simplest solution if showing version name in css path
like : pub/static/version323334/
then run this query in my sql
INSERT INTO 'core_config_data' ('path', 'value')
VALUES ('dev/static/sign', 0)
ON DUPLICATE KEY UPDATE value = 0;
after that clear the config cache
bin/magento cache:clean config
you can also disable static file version form admin
Changing the
Options +FollowSymLinks
to
Options +SymLinksIfOwnerMatch
in the .htaccess file inside the pub folder in your Magento root directory fixed the problem for me.
If you are facing theming issue after Installation in magento 2. You can follow these steps :
INSERT INTO core_config_data (path, value) VALUES ('dev/static/sign', 0) ON DUPLICATE KEY UPDATE value = 0;
UPDATE
dbname
.core_config_data
SETvalue
= '0' WHEREcore_config_data
.path
LIKE '%web/seo/use_rewrites%';
sudo rm -rf var/di var/generation/ var/page_cache/ var/cache/ pub/static/frontend/ pub/static/adminhtml/ pub/static/_requirejs/ pub/static/deployed_version.txt
sudo chmod -R 777 var/* pub/*
sudo php bin/magento setup:upgrade
sudo php bin/magento setup:static-content:deploy
After these steps, you will be able to see proper theme.
Might be the issue at mod rewrite. Please check the mod rewrite setting at the server. If you have using apache then use below steps for enabling mod rewrite
sudo a2enmod rewrite
sudo service apache2 restart
Just delete everything except .htaccess in pub\static and refresh the page will resolve the issue .
1.Just delete var/view-processed/pub folder.Also delete pub/static/frontend/ all folders.
2.In mysql core_config_data,check whether dev/static/sign has scope-default ,scope id- 0 and value 0.If field not present, create it.
3.Then run php bin/magento setup:static-content:deploy -f php bin/magento cache:flush
In command line Magento root directory use the following commands.
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento setup:static-content:deploy
or
php bin/magento setup:static-content:deploy -f
php bin/magento setup:static-content:deploy [locales]