Reputation: 121
I have installed magento 2 successfully on localhost but I am not able to see admin panel as it render 404 error to me.
Secondly, When I open front-end then CSS and JavaScript is not loading.They also renders 404 errors.
Also When I try to run command:
{your Magento install dir}/bin/magento setup:static-content:deploy
I got the following error
[InvalidArgumentException]
There are no commands defined in the "setup:static-content" namespace.
Upvotes: 12
Views: 95092
Reputation: 3060
If all of the above is not working try to set 0 in the below paths in core_config_data
table
web/secure/use_in_frontend
web/secure/use_in_adminhtml
Upvotes: 0
Reputation: 19
I've faced the same issue and i get it resolved using the following procedure.
php bin/magento setup:static-content:deploy
php bin/magento c:f
sudo chmod -R 777 var/ pub/ generated/
sudo chown -r your-website-user:your-website-group
ln -s static pub/static
ln -s media pub/media
Upvotes: 0
Reputation: 1164
Though it is old question, its answers could not help me to fix my issue what would generate same error message. I suggest the followings:
tail var/log/system.log
Or find if there is any error in php error log file
If you find isolated error, fix it.
sudo rm -rf pub/static sudo rm -rf var/cache sudo rm -rf var/composer_home sudo rm -rf var/generation sudo rm -rf var/page_cache sudo rm -rf var/view_preprocessed
After deleting them, you can re-create them by executing the following commands:
sudo php bin/magento setup:static-content:deploy -f
Upvotes: 3
Reputation: 11
If you are facing theming issue after Installation in Magento 2. You can follow these steps :
Run this query:
INSERT INTO core_config_data (path, value) VALUES ('dev/static/sign', 0) ON DUPLICATE KEY UPDATE value = 0;
For local machine run this query:
UPDATE core_config_data
SET value
= '0' WHERE
core_config_data
.path
LIKE '%web/seo/use_rewrites%';
Remove all the files from pub and var directory:
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
Give Permission to var and pub directories of your project:
sudo chmod -R 777 var/* pub/*
Upgrade Setup:
sudo bin/magento setup:upgrade
Deploy content:
sudo php bin/magento setup:static-content:deploy
After these steps, you will be able to see proper theme.
Upvotes: 1
Reputation: 51
if you have tried php bin/magento setup:static-content:deploy
or any such related commands and the issue is still there. Then you may like to try this.
This fix addresses No Css and Javascript and Admin 404 page issues after magento installation (v2.3).
step 1 : open httpd.conf
.
step 2 : search for
AllowOverride
(may be written as AllowOverride all)Require
(may be written as Require local)in directory section of this file.
step 3 : Change
AllowOverride
to AllowOverride All
Require
to Require All Granted
Upvotes: 0
Reputation:
below Solution worked: Please un below query in database. INSERT INTO core_config_data (path, value) VALUES ('dev/static/sign', 0) ON DUPLICATE KEY UPDATE value = 0; https://magento.stackexchange.com/questions/97209/magento-2-css-and-javascript-not-loading-from-correct-folder
Upvotes: 0
Reputation: 1687
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
Upvotes: 19
Reputation: 31
Changing dev/static/sign
to 0
in core config data worked for me
then,
bin/magento cache:flush
then,
php bin/magento setup:static-content:deploy -f
Upvotes: 3
Reputation: 119
Run the following commands in CLI interface of your Magento2 root folder:
$ php bin/magento setup:static-content:deploy
$ php bin/magento indexer:reindex
Then delete var folder by this command at your root of magento2.
$ rm -rf var/*
Then refresh your homepage and admin panel.
Upvotes: 1
Reputation: 11
After trying all the solutions mentioned over here and in https://magento.stackexchange.com/questions/97209/magento-2-css-and-javascript-not-loading-from-correct-folder
We were not able to get this thing going.
But this is very weird answer but it worked for us.
Firstly, We cleared the cache and ensured that the static files are being created inside pub/static/ folder. Then checked the deployed_version.txt contains same version number as being loaded in the URL.
Our main culprit was the .htaccess file which was present in pub folder. There should be just one .htaccess file inside pub/static folder but not in pub folder. This did the trick for us after searching everywhere.
Hope it helps others looking for the similar answer.
Upvotes: 1
Reputation: 21
The following answer works for me, thanks:
open file MAGENTO_ROOT/app/etc/di.xml
and replace below code form line number 574
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink
with
Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
DELETE
MAGENTO_ROOT/pub/static/_requirejs
MAGENTO_ROOT/pub/static/adminhtml
MAGENTO_ROOT/pub/static/frontend
Upvotes: 0
Reputation: 221
This One Worked for Me.
use this Command php bin/magento setup:static-content:deploy
Step 1 : In CMD Open your root directory using cd command
Step 2 : php bin/magento setup:static-content:deploy
- run this Command
then,Check Your pub/static
folder, CSS and Js files will be available there
Refer this
Upvotes: 19
Reputation: 1159
Please follow the steps below to get rid of this issues.
1) Download the Magento 2.
2) Extract this in your www OR htdocs directory.
3) Install the magento. Do not use localhost, use 127.0.0.1 in store url and admin url.
4) After successful installation DO NOT RUN MAGENTO.
5) Now delete the cache / session of magento 2. Go to the below mentioned paths and delete the files.
Magento Root > var > cache > Delete all files
Magento Root > var > page_cache > Delete all files
Magento Root > var > session > Delete all files
6) Change the behavior of symlinks for some static resources as mentioned below:-
When Magento 2 is not in production mode, it will try to create symlinks for some static resources on local server. We have to change that behavior of Magento 2 by going to edit ROOT > app > etc > di.xml
file. Open up di.xml in your favorite code editor, find the virtualType name="developerMaterialization"
section. In that section below, you will find an item <item name="view_preprocessed" xsi:type="object">
which needs to be modified. You can modify it by changing the following content:
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink
To:
Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
7) Delete all the files except .htaccess
Magento Root > pub > static > Delete all files except **.htaccess**
ITS DONE. Now you may run the magento Front and Backend URL
Upvotes: 0
Reputation: 667
Try the same command as root user by adding sudo like below
sudo php bin/magento setup:static-content:deploy
Upvotes: 6
Reputation: 8366
Usually this happens because of failed compilation in the var/di
folder. You can solve it by deleting everything in your var folder.
Also for future, don't forget that magento command line implements symfony verbosity levels: append --v
or ---v
to your command to see the exact error.
Upvotes: 0
Reputation: 1
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.
Let me know if any issue. :)
Upvotes: -1
Reputation: 2669
We also faced this issue once, and sorted it out. For this you need to go directly in bin
directory and use that command. For example,
php magento setup:static-content:deploy
Some times if you run this command outside of bin
or from any directory
php bin/magento setup:static-content:deploy
then you will get error like (may be it is because of linux system),
[InvalidArgumentException]
There are no commands defined in the "setup:static-content" namespace.
Update:
If any *.xml
file in our custom modules is not valid then the same error will come.
Upvotes: 2
Reputation: 14990
This worked for me:
1) Static content deploy. Run the below command from Magento 2 root directory:
sudo php bin/magento setup:static-content:deploy
2) Clear everything in var/cache
directory or flush the Magento 2 cache using the below command:
php bin/magento cache:flush
3) Set proper permissions for Magento 2 directories by executing the below command from Magento 2 root directory:
sudo find . -type d -exec chmod 770 {} \; && sudo find . -type f -exec chmod 660 {} \; && sudo chmod u+x bin/magento
Hope this helps.
Upvotes: 0
Reputation: 1625
This error happens when you have not setup permission correctly. It can't see that the command actually exist.
Try running:
sudo find . -type d -exec chmod 770 {} \; && sudo find . -type f -exec chmod 660 {} \; && sudo chmod u+x bin/magento
sudo chown -R $(whoami):www-data .
Change www-data to appropriate webserver user. e.g. apache or www-data.
Upvotes: 0
Reputation: 1781
Provide static deploy command like this:
php bin/magento setup:static-content:deploy
Please set full permission for pub and var folders.
Upvotes: 1
Reputation: 772
Just simple and right solution, hope usefull.
Go to your wampserver icon and click on it and than
After this re-start all services and check it .
Upvotes: 0
Reputation: 3427
Just Open the
MAGENTO_ROOT/app/etc/di.xml
and replace below code form line number 574
<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
TO
<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
DELETE
MAGENTO_ROOT/pub/static/_requirejs
MAGENTO_ROOT/pub/static/adminhtml
MAGENTO_ROOT/pub/static/frontend
Upvotes: 0
Reputation: 199
you just need to run this command on your Terminal
php bin/magento setup:static-content:deploy
Make sure you give the the root path of your magento in terminal and then run the above command
Upvotes: 0
Reputation: 1175
If you facing problem of css and design after installation in Windows, follow these steps
php bin/magento setup:static-content:deploy
php bin/magento indexer:reindex
var/cache
Upvotes: 0
Reputation: 874
I also had same issue and below step solves my issue:
Step 1: Navigate to directory where magento is installed.
Step 2: Run "sudo php bin/magento setup:static-content:deploy"
Upvotes: 1