6

I have installed Magento 2 successfully.

When i am trying to open front end that looks like this picture and backend shows 404 error. how to solve this?

CSS error on frontend

Rafael Corrêa Gomes
  • 13,309
  • 14
  • 84
  • 171
Saravanan DS
  • 1,126
  • 1
  • 18
  • 42

10 Answers10

10

After static content deploy my js and css not loading because in url deploy version is added so insert Query in my database.

INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('default', 0, 'dev/static/sign', '0');

Or in Admin below screenshot setting static file settings enter image description here

I hope this will work

Solution : 2 Permission issue so correct your permissiom first of all Command in your teminal

chmod -R 777 var pub
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Solution: 3 Deploy according to your language.

bin/magento setup:static-content:deploy en_US nl_NL -f 
php bin/magento cache:flush
Sanjay Chauhan
  • 324
  • 3
  • 8
6

I hope this will help you

If you are using wamp server on windows then

C:\wamp\bin\php\php5.5.12>php.exe C:\wamp\www\<Magento root directory>\bin\magento setup:static-content:deploy in your CLI.

MaYaNk
  • 1,730
  • 1
  • 16
  • 27
6

Deploy static content using Magento 2 CLI. If you don't know how to do it, I have written everything in the answer below with the reasons why this happens and how to solve it. Please check it out:

https://magento.stackexchange.com/a/97230/34408

Fayyaz Khattak
  • 2,102
  • 2
  • 18
  • 26
  • Thanks @Fayyaz. I tried your solution #2. Front looks well but backend results 404 error. i have cleared cache and done reindex also. – Saravanan DS Jun 17 '16 at 06:30
  • I think you should try installing Magento 2 again with the method I defined because, with my Solution # 2, people get benefit from it. It must be an issue with files. Try installation again. – Fayyaz Khattak Jun 17 '16 at 06:33
  • Also, one more thing. In php.ini file, change max_execution_time to 500, memory_limit to 2048M, post_max_size to 2048M, upload_max_filesize to 2048M and max_file_uploads to 2048. – Fayyaz Khattak Jun 17 '16 at 06:34
  • only home shows the contents well. The other pages like sign in, create account, contact us etc are shows 404 error. – Saravanan DS Jun 17 '16 at 07:01
  • I have installed another fresh magento 2. done the same things like this. Occurs the same issue now also. – Saravanan DS Jun 17 '16 at 07:17
  • 1
    Finally need to enable module rewrite in wamp. Now it will work. check this link – Saravanan DS Jun 17 '16 at 07:51
  • @SaravananDS great at least you solve the issue. Yes the rewrite module is necessary for Magento 2. – Fayyaz Khattak Jun 17 '16 at 08:37
  • Afer Deploy static content, still my website looks like above screen shot.... May i how to solve this question. – zus Nov 21 '17 at 05:49
5

have been in the same situation, and concluded it was because of deleting htaccess file also in pub/static.

If using some VCS you can recover it easily or as indicated in this answer go to the official Magento2 repository and retrieve your missing file.

medmek
  • 594
  • 7
  • 20
2

You need to deploy static content.

Run

php bin/magento setup:static-content:deploy

From your root

Asish Hira
  • 1,981
  • 1
  • 17
  • 39
1

Run these commands below, it normally resolves many issues including that.

alias mage="php -d memory_limit=-1 -f bin/magento"

chmod -R 775 pub/static/ var/ pub/media/ &&
rm -rf var/view_preprocessed/ var/cache/ var/page_cache/ var/tmp/ var/generation/ pub/static/frontend/ ;
php -r "opcache_reset();"
mage cache:flush &
mage indexer:reindex &
mage setup:static-content:deploy;
mage setup:upgrade &&
mage setup:db-data:upgrade &&
mage dev:source-theme:deploy &&
chmod -R 775 pub/static/ pub/media/ var/
Rafael Corrêa Gomes
  • 13,309
  • 14
  • 84
  • 171
0

Run below command in your current root ( mage22 )

php magento setup:static-content:deploy

Just Open the

MAGENTO_ROOT/app/etc/di.xml

and replace below code form line number around 574

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

replace

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

Clear cache, deploy static content and check now.

Hope this helps.

Krishna ijjada
  • 8,927
  • 6
  • 41
  • 70
0

If you have added new code or made any change in code then you have to compile the code for that you can run the following commands :

1) Go to your Magento project root directory.
2) sudo rm -rf var/cache var/generation var/di
3) sudo php bin/magento setup:upgrade
4) sudo php bin/magento setup:di:compile
5) sudo chmod 777 -R var/

after this can restart your server

sudo /etc/init.d/apache2 restart

and see your admin panel hope it would be running.

0

For those who are still having issues loading backend (admin portal), - for me it was always throwing a 404, its just a matter of changing the AllowOverride directive from "none" to "all" in the respective document root.

<Directory "/var/www/html">
  AllowOverride All
  Order allow,deny
  Allow from all>
</Directory>

And finally, restart apache/httpd and load your site again !

Abhishek Tripathi
  • 2,885
  • 2
  • 18
  • 37
anrajme
  • 111
  • 1
0

if you are using xampp server use bellow command in your cmd to load static files:

D:\xampp\php> php.exe D:\xampp\htdocs\<Magento root directory>\bin\magento setup:static-content:deploy -f