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?
10 Answers 10
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:
-
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– Saravanan DS2016年06月17日 06:30:40 +00:00Commented Jun 17, 2016 at 6: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– Fayyaz Khattak2016年06月17日 06:33:48 +00:00Commented Jun 17, 2016 at 6: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– Fayyaz Khattak2016年06月17日 06:34:40 +00:00Commented Jun 17, 2016 at 6:34
-
only home shows the contents well. The other pages like sign in, create account, contact us etc are shows 404 error.Saravanan DS– Saravanan DS2016年06月17日 07:01:32 +00:00Commented Jun 17, 2016 at 7:01
-
1Finally need to enable module rewrite in wamp. Now it will work. check this linkSaravanan DS– Saravanan DS2016年06月17日 07:51:23 +00:00Commented Jun 17, 2016 at 7:51
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
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.
-
remove cache and try againMaYaNk– MaYaNk2016年06月17日 06:12:10 +00:00Commented Jun 17, 2016 at 6:12
-
its work for me, if developer mode enables then use -f with commandSurya prakash Patel– Surya prakash Patel2019年08月01日 03:38:06 +00:00Commented Aug 1, 2019 at 3:38
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.
You need to deploy static content.
Run
php bin/magento setup:static-content:deploy
From your root
-
@ashish Thanks for your reply. I have tried this. after this process front shows as well. but backend results the same 404.Saravanan DS– Saravanan DS2016年06月17日 06:08:18 +00:00Commented Jun 17, 2016 at 6:08
-
Did you tried to clear the cache??Asish Hira– Asish Hira2016年06月17日 06:11:02 +00:00Commented Jun 17, 2016 at 6:11
-
yes @asish. i have cleared cache using
php bin/magento cache:flushand done reindex usingphp bin/magento indexer:reindex.Saravanan DS– Saravanan DS2016年06月17日 06:14:55 +00:00Commented Jun 17, 2016 at 6:14 -
@ Saravanan DS Try string replace i mentioned at the answer ( /app/etc/di.xml ) Then clear the cache, setup upgrade.Krishna ijjada– Krishna ijjada2016年06月17日 06:15:36 +00:00Commented Jun 17, 2016 at 6:15
-
yes done the same thing also in ` /app/etc/di.xml `. now also same error.Saravanan DS– Saravanan DS2016年06月17日 06:27:53 +00:00Commented Jun 17, 2016 at 6:27
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/
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.
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.
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 !
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
Explore related questions
See similar questions with these tags.
mod_rewriteenable