Question

I am running Magento 2 locally in developer mode

After installing i would not expect to have to run php bin/magento setup:static-content:deploy if in developer mode.

However, the only directory under static is _requirejs and all css and other assets generate a 404 on the frontend.

Is the php bin/magento setup:static-content:deploy command required even in developer mode or do i have an issue with this?

Was it helpful?

Solution

If you are in Apache:

  1. Check you have the correct .htaccess file under pub/static folder https://github.com/magento/magento2/blob/2.2/pub/static/.htaccess. Check https://github.com/magento/magento2/blob/2.2/pub/static/.htaccess#L21 which redirects requests to static.php
  2. Make sure your mod rewrite module is working properly.
  3. Make sure apache is reading .htaccess files.

Apache 2.2 AllowOverride All Order allow,deny Allow from all

Apache 2.4 AllowOverride All Require all granted

If you are in Nginx:

Update configurations using https://github.com/magento/magento2/blob/2.2/nginx.conf.sample. Check https://github.com/magento/magento2/blob/2.2/nginx.conf.sample#L111 which redirects requests to static.php

OTHER TIPS

Also, if you are running Apache: make sure that mod_rewrite module is enabled.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top