12

I'm having this weird error and I did not suceed to find the origin. First of all I would like to say that I succeeded to perform some installation of Magento 2 on a windows os with a xampp server before.

I'm now trying to install a magento instance on Windows Server with IIS

Basically after configuring composer etc.. the installations runs well. No error mentioned during the installation process etc..

However at the end when I try to access at the backend or the front store it display the page but no css or images files are loaded. When I looked in the missing ressources, basically I have 404 errors for all css & images files supposed to be located in the following folders

pub/static/frontend/*
pub/static/backend/*

Physically in my folder pub/static/ there is only the _requirejs folder and .htaccess file but no folder frontend and backend

I guess the folder frontend and backend are generated automatically because they are not by default in the initial clone of magento 2.0

So if anyone has got any ideas of where the problem could come from.

Additional information to consider: I have checked the permissions, the web server has full access (read and write) on every folders and file magento 2.0 root directory.

5 Answers 5

20

An easier would be to run below command from magento root folder.

php bin/magento setup:static-content:deploy

This will feed the content perfectly in respective folders. If you have specific language then run like below.

php bin/magento setup:static-content:deploy en_US
php bin/magento setup:static-content:deploy en_GB
Sign up to request clarification or add additional context in comments.

6 Comments

If you have only one language then you can use php bin/magento setup:static-content:deploy en_US
Yeah, why do we have to google this sort of stuff...?
That is, I do find mention of these "static" resources in the documentation, but for the "easy" installation route, seems like this sort of stuff should be called out in the same tutorials..
it gives me an error : [InvalidArgumentException] There are no commands defined in the "deploy:mode" namespace. please help
Thank you, php-bugs, for mentioning the additional language parameter! I changed my store default language to en_GB, and deployed the static content. Boom - 404 on css and js files. Running php bin/magento setup:static-content:deploy en_GB fixed it.
|
3

The static content deploy process is described as below:

1) Delete adminhtml,frontend and _requirejs folders from pub/static folder.

2) Please don't delete the .htacces file in that pub/static folder.

3) Delete all folders in the directory var/cache.

4) Give 777 permission to both pub and var folders.

5) Run the command:

php bin/magento setup:static-content:deploy

1 Comment

777 is not the solution, nor manually deleting folders, this is just a hack that is not useful in real life applications
2

You get 404 responses probably because you don't have mod_rewrite enabled. You should enable it. But it can work without it. There is a 'cache' system for these static resources. navigate to the folder dev/tools/Magento/Tools/View and run this in the command line

php deploy.php

It works perfect. But still if you have issues then let me know.

------ EDIT ------

Edit as per the Chirag Bhavsar's answer.Enter below command from root of the Magento folder. New command will be

php bin/magento setup:static-content:deploy

4 Comments

Hello , thanks for your input however I don't suceed to find this deploy.php in the mentionned folder. In fact the folder View does not exist.
Try below steps. 1. enable "developer" mode (add SetEnv MAGE_MODE developer in root .htaccess file) 2. remove everything, except .htaccess file from pub/static folder 3. open the web-site 4. find one of non-loaded jquery resources and open it in the browser If any exception happens during processing of this resource, the error should be displayed on step 4. If not, please, look at pub/static folder - it should contain only .htaccess file. ...to be continue (more in below comment).
Open up app/etc/di.xml and find the virtualType name="developerMaterialization" section. In that section you'll find an item name="view_preprocessed" that needs to be modified or deleted. You can modify it by changing the contents from Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink to Magento\Framework\App\View\Asset\MaterializationStrategy\Copy Delete the files under pub/static to get rid of any existing symlinks. You may want to be careful not to delete the .htaccess file. Let me know if it works for you.
Hello Soni, Thanks your feedbacks, but I had an answer before from magento team. github.com/magento/magento2/issues/1312 . Running the cli php command "/bin/magento setup:static-content:deploy" created the files properly, altough it was long.
1

When installing Magento 2.1.4 from scratch I also confronted with permissions problems and CSS and JS not loading in the page because they were not found by the server although I just ran

php bin/magento setup:static-content:deploy

and

php bin/magento cache:clean

It turned out that this setting is needed in the database to access the CSS and JS and have the site loading after first magento2 install.

insert core_config_data (config_id, scope, scope_id, path, value) values (null, 'default', 0, 'dev/static/sign', 0); 

This seemed to be the only sollution to have the site up and working.

1 Comment

Excellent! The setting in core_config_data did the trick for me.
0

First please delete 'static' folder from 'pub/static' in magento 2 before delete this folder please copy .htaccess file from this folder in other folder in your pc. <-- Changes in app\code\Magento\Developer\etc\di.xml -->

Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink  

<--to-->

Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

After that using cmd/shell run these commands

php bin/magento setup:static-content:deploy -f

and

php bin/magento deploy:mode:set developer

After runing these commands .Paste old .htaccess file into new static folder. Thats it. And Clear Full Cache.

php bin/magento cache:clean

Your project working now enjoy!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.