Magento2: Pub/Static directory is empty

Created on 14 Jan 2015  Â·  10Comments  Â·  Source: magento/magento2

I did a fresh install it went successful after a lot of tries.

Both front-end and admin wont load CSS/JS/ files are not created in pub/static directory & as one directory _requireJs

Also frontend and adminhtml directories do not exist in pub/static.

Fixed in 2.3.x Fixed in 2.4.x Format is not valid

Most helpful comment

Additionally to the big documentation @mazhalai pointed to, here is how static view files are related to mod_rewrite.

  1. Browser requests a file
  2. It's not found, as it doesn't exist by default
  3. Rewrite rule in pub/static/.htaccess discovers it and redirects to pub/static.php
  4. pub/static.php searches for the requested file using fallback mechanism described in the article mentioned by @mazhalai
  5. If the file is found, it's published somewhere to pub/static/ folder (e.g., pub/static/frontend/Magento/blank/css/file.css)
  6. On the next request, the file already exists, so it's just returned as a static content w/o involving mod_rewrite

This is default behavior (when default application mode is used).
In developer mode the file is not even published to pub/static folder. It goes through pub/static.php entry point every time.
In production mode it's expected that all files are published to pub/static folder, so pub/static.php should not be involved at all. If it is, it just returns 404 error. There is a tool for deploying static view files and it should be used to make production mode work (dev/tools/Magento/Tools/View/deploy.php)

We're thinking how UX can be improved in this area, but right now it works as described above.

All 10 comments

For further info, i was installing it with sample data.

Is Apache mode_rewrite enabled and its configuration is allowed from .htaccess files of your web-site?

@buskamuza .htaccess was not allowed. I allowed .htacess and magento showed up the theme.

Could you put some light on this behavior of magento?

Thanks for the help. :)

More documentation about this behavior here

Additionally to the big documentation @mazhalai pointed to, here is how static view files are related to mod_rewrite.

  1. Browser requests a file
  2. It's not found, as it doesn't exist by default
  3. Rewrite rule in pub/static/.htaccess discovers it and redirects to pub/static.php
  4. pub/static.php searches for the requested file using fallback mechanism described in the article mentioned by @mazhalai
  5. If the file is found, it's published somewhere to pub/static/ folder (e.g., pub/static/frontend/Magento/blank/css/file.css)
  6. On the next request, the file already exists, so it's just returned as a static content w/o involving mod_rewrite

This is default behavior (when default application mode is used).
In developer mode the file is not even published to pub/static folder. It goes through pub/static.php entry point every time.
In production mode it's expected that all files are published to pub/static folder, so pub/static.php should not be involved at all. If it is, it just returns 404 error. There is a tool for deploying static view files and it should be used to make production mode work (dev/tools/Magento/Tools/View/deploy.php)

We're thinking how UX can be improved in this area, but right now it works as described above.

@mrugeshrocks, are there other questions remaining that you'd like to ask related to your original question?

Thanks @buskamuza & @mazhalai

With this im closing the issue.

Just as a side note…
I had to add RewriteBase /pub/static/ when using a VirtualDocumentRoot.

Hi @mrugeshrocks. Thank you for your report.
The issue has been fixed in magento/graphql-ce#973 by @VitaliyBoyko in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.4 release.

Was this page helpful?
0 / 5 - 0 ratings