How to fix the problem of loading css and javascript files?

So many users have the problem! So what to do?

1. Set the proper permissions and ownership

You should set the proper filesystem permissions and ownership: http://devdocs.magento.com/guides/v2.0/install-gde/install/file-system-perms.html

2. Deploy the static content

The static content is deployed automatically in the developer mode.
I recommend to use the developer modue during a store’s development.
If you run a store in the production mode then you should deploy the static content manually.

3. Ensure you have not missed the .htaccess files

What .htaccess files Magento 2 uses?

4. Are you running Magento in a subdirectory?

If you have installed Magento 2 into a subdirectory (/store, for example) then you should adjust your webserver.
See: How to adjust Apache webserver (through .htaccess files) to run Magento in a subdirectory?

If you use Nginx webserver then see the instructions:

5. The problem could be caused by a lack of memory for the Less compiler

How to fix the «Allowed memory size exhausted» / «Out of memory / Bad gateway» failure in Magento/Framework/ObjectManager/Relations/Runtime.php?.

1 Like

Login to ssh, go to magento directory for instance i’m

cd /var/www/html/magento

1: rm -rf var/di/* var/generation/* var/cache/* var/page_cache/* var/view_preprocessed/* var/composer_home/cache/*

2: sudo chmod 777 var -R
3: sudo chmod 777 pub -R

4: sudo php bin/magento setup:static-content:deploy

5: Repeat step 2 & 3.