phpcomposer-phpmagento2

magento2.4.6 can't load css and js (layout) after installation on windows 10


I'm very confusing what's the matter? I use :

xampp3.3
php 8.2
magento 2.4.6
elasticsearch 8.8.1

I did all the others said in forums and other questions in stackoverflow or magento stackexchange. but my problem didn't resolve.

enter image description here

what I did:

  1. setting in the database core_config_data table:

INSERT INTO core_config_data (path, value) VALUES ('dev/static/sign',0) ON DUPLICATE KEY UPDATE value = 0;

and set 'web/seo/use_rewrites' to 0 due to an answer in forums.

  1. remove folders in 'pub\static' and 'var'.
  2. change owner and give permissions:

takeown /f . /r

this commands one by one:

icacls .\pub /grant Everyone:F /t
icacls .\var /grant Everyone:F /t
icacls .\app\etc /grant Everyone:F /t
  1. on httpd.conf the line below is active: LoadModule rewrite_module modules/mod_rewrite.so
  2. add this section to httpd.conf:

<Directory "C:\xampp\htdocs\magento2"> Options Indexes SymLinksifOwnerMatch MultiViews AllowOverride All Require all granted

and

timeout 300

  1. in di.xml, change developerMaterialization value from symLink to Copy.

  2. run this commands one by one

    php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f php bin/magento indexer:reindex php bin/magento cache:flush

  3. delete cache folder under var and even clean cashe by:

    php bin\magento cache:clean php bin\magento cache:flush

I use localhost, and also use 127.0.0.1 in store url and admin url. magento2 is loaded but without any css. and the admin panel not loaded at all (404 error). I test on developer and also production mode.

my installation command for magento 2.4.6 is :

php bin/magento setup:install --base-url=http://localhost/magento2/  --db-host=localhost --db-name=magento --db-user=root --db-password=root  --admin-firstname=E --admin-lastname=R --admin-email=some@gmail.com  --admin-user=admin --admin-password=admin123 --language=en_US  --use-rewrites=1 --search-engine=elasticsearch8 --use-sample-data --cleanup-database

I spent much time but without any success.


Solution

  • There are many reason for this, first at all, you need to open the 404 link in browser to see the actual issue, sometime It's the issue with permission (need to check the Apache/Nginx log)

    Second, reason likely to happen because files did not generate properly, for this case, you need to enable the developer mode

    See here: https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-mode.html#change-to-developer-mode

    Then run command bin/magento setup:upgrade

    Hope this work for you.