magento 2.1.3 pub/media/styles.css file not existedNo images or JS on new Magento 2 installationMagento 2.2.4 : Missing media/styles.css from Sample Data siteAfter installation, I have problems with Magento 2Issues with deplyoing static files command and frontend loses css and jsWhy its adding version_no in js and css url in magento2?CSS not loading on page within Magento 2 pageCannot install module in Magento 2magento2 admin dashboard not loading css and jsWhy do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Magento 2 Generate static files without gulpIn production mode the site does not loadMagento2 Getting error as variable @baseUrl is undefined in file /var/view_preprocessed

Do beef farmed pastures net remove carbon emissions?

How far did Gandalf and the Balrog drop from the bridge in Moria?

Why is there a large performance impact when looping over an array over 240 elements?

Is it okay for a ticket seller in the USA to refuse to give you your change, keep it for themselves and claim it's a tip?

Why did I get only 5 points even though I won?

Not going forward with internship interview process

Email address etiquette - Which address should I use to contact professors?

Solution to German Tank Problem

0xF1 opcode-prefix on i80286

Does Molecular Weight of a Gas affect its lifting properties at the same velocity over the same wing?

Annotating a table with arrows

First amendment and employment: Can a police department terminate an officer for speech?

Why did Gandalf use a sword against the Balrog?

How can God warn people of the upcoming rapture without disrupting society?

Breadcrumb history decision

How to assign many blockers at the same time?

How can I categorize files in a directory based on their content?

A torrent of foreign terms

Bitcoin successfully deducted on sender wallet but did not reach receiver wallet

A Non Math Puzzle. What is the middle number?

How do some PhD students get 10+ papers? Is that what I need for landing good faculty position?

What should I call bands of armed men in the Middle Ages?

What does the phrase "pull off sick wheelies and flips" mean here?

Loading military units into ships optimally, using backtracking



magento 2.1.3 pub/media/styles.css file not existed


No images or JS on new Magento 2 installationMagento 2.2.4 : Missing media/styles.css from Sample Data siteAfter installation, I have problems with Magento 2Issues with deplyoing static files command and frontend loses css and jsWhy its adding version_no in js and css url in magento2?CSS not loading on page within Magento 2 pageCannot install module in Magento 2magento2 admin dashboard not loading css and jsWhy do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Magento 2 Generate static files without gulpIn production mode the site does not loadMagento2 Getting error as variable @baseUrl is undefined in file /var/view_preprocessed






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















These are the steps I used to deploy content:



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


  2. sudo chmod 777 -R var pub pub/media app/etc


  3. php bin/magento setup:static-content:deploy


  4. php bin/magento cache:clean


But when I load the local site, there is no pub/media/styles.css file. Could anyone help me to fix this?



Error screenshot










share|improve this question


























  • sudo chmod 777 -R var & check

    – Ankit Shah
    Jan 5 '17 at 3:57











  • I did this. Please look at step 2 I posted above. That command includes var as well.

    – Tyler Bean
    Jan 5 '17 at 4:39

















0















These are the steps I used to deploy content:



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


  2. sudo chmod 777 -R var pub pub/media app/etc


  3. php bin/magento setup:static-content:deploy


  4. php bin/magento cache:clean


But when I load the local site, there is no pub/media/styles.css file. Could anyone help me to fix this?



Error screenshot










share|improve this question


























  • sudo chmod 777 -R var & check

    – Ankit Shah
    Jan 5 '17 at 3:57











  • I did this. Please look at step 2 I posted above. That command includes var as well.

    – Tyler Bean
    Jan 5 '17 at 4:39













0












0








0








These are the steps I used to deploy content:



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


  2. sudo chmod 777 -R var pub pub/media app/etc


  3. php bin/magento setup:static-content:deploy


  4. php bin/magento cache:clean


But when I load the local site, there is no pub/media/styles.css file. Could anyone help me to fix this?



Error screenshot










share|improve this question
















These are the steps I used to deploy content:



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


  2. sudo chmod 777 -R var pub pub/media app/etc


  3. php bin/magento setup:static-content:deploy


  4. php bin/magento cache:clean


But when I load the local site, there is no pub/media/styles.css file. Could anyone help me to fix this?



Error screenshot







magento2 css magento-2.1.3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 1 at 13:22









Mohit Rane

1,20718 bronze badges




1,20718 bronze badges










asked Jan 5 '17 at 3:43









Tyler BeanTyler Bean

631 silver badge13 bronze badges




631 silver badge13 bronze badges















  • sudo chmod 777 -R var & check

    – Ankit Shah
    Jan 5 '17 at 3:57











  • I did this. Please look at step 2 I posted above. That command includes var as well.

    – Tyler Bean
    Jan 5 '17 at 4:39

















  • sudo chmod 777 -R var & check

    – Ankit Shah
    Jan 5 '17 at 3:57











  • I did this. Please look at step 2 I posted above. That command includes var as well.

    – Tyler Bean
    Jan 5 '17 at 4:39
















sudo chmod 777 -R var & check

– Ankit Shah
Jan 5 '17 at 3:57





sudo chmod 777 -R var & check

– Ankit Shah
Jan 5 '17 at 3:57













I did this. Please look at step 2 I posted above. That command includes var as well.

– Tyler Bean
Jan 5 '17 at 4:39





I did this. Please look at step 2 I posted above. That command includes var as well.

– Tyler Bean
Jan 5 '17 at 4:39










4 Answers
4






active

oldest

votes


















1














You also need to run setup:di:compile and then give permission 777 (Which is not preferable on production mode).



Run all the commands in below sequence :



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


  2. php bin/magento setup:di:compile run this command. It will generate
    var/generation and other directories again.


  3. sudo chmod 777 -R var pub pub/media app/etc (Give permissions to generated directories)


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

  5. php bin/magento cache:clean

Refer this link for more details - After installation, I have problems with Magento 2



It will resolved your issue.






share|improve this answer



























  • I tried as you suggested but the styles.css file is still missing.

    – Tyler Bean
    Jan 5 '17 at 6:07











  • @TylerBean check this link - magento.stackexchange.com/questions/96289/….

    – Manthan Dave
    Jan 5 '17 at 6:17


















0














In your Magento pub /static folder .htaccess file chnge so copy that in another folder and paste it
It is working for you






share|improve this answer
































    0














    You have deleted your .htaccess file from pub/static/.htaccess



    please unhide files on that folder if check if available, else copy it from another magento setup and copy - paste it on "pub/static/ HERE "



    then follow below commands.



    1. sudo chmod 777 -R var pub pub/media app/etc

    2. php bin/magento setup:static-content:deploy

    3. php bin/magento cache:clean

    Hope this will help you.






    share|improve this answer



























    • I checked and the .htaccess is still available on pub/static. I think it's not the problem. I downloaded zipped magento and copy the pub/media/styles.css from there to my project and it's working now. It's really hard to explain why the file is not created.

      – Tyler Bean
      Jan 5 '17 at 7:33











    • Great to hear your problem solved... :) @TylerBean

      – Yogesh
      Jan 5 '17 at 8:11












    • Thanks a lot. But it's still a mystery why the file is not created. :)

      – Tyler Bean
      Jan 5 '17 at 8:56


















    0














    There can be many explainations according to the informations provided.




    Solution for 404 errors on static files



    Files and folders permissions and/or ownership



    This is the most probable reason as we can also see 404 error on other static files. In that case you should physicaly see the file on the web server.



    You are running the command sudo chmod 777 -R var pub pub/media app/etc (which is a bad practice by the way, especially for the app/etc folder which contains sensitive data), your folders are still empty (you just ran a rm -rf on their content).



    When you deploy static files, the files and folders generated are not generated as 777.



    In most cases (following Magento files and folders permissions best practices), this shouldn't be a problem (and it's a normal behavior).



    But if you are running the commands using a different user than the user running your Magento application (ex. : using root for commands, and www-data for website), you could end up with permissions issues, because your Magento application may not be authorized to read the files from this different user (who could also be in a different group).



    In that case :



    • Fix user/group ownership if necessary : chown -R user:group /path/to/magento/

    • Use the same user than the web server user

      • In some case you are not able to log in as the web server user, you should then use a user in the same group

      • More details here (Magento 2 official documentation)


    Missing pub/static/.htaccess file



    This point is more about the other 404 errors on the static files, rather than the pub/media/styles.css file



    When changes are made on the design, static files are often purged (typicaly with a rm -rf pub/static/*).



    You may have accidentaly removed the pub/static/.htaccess file while doing so (with a manual purge for example).



    This file is mandatory for apache servers, as it will allow Magento to redirect the versioned URL (yoursite.local/static/someversion/frontend/path/to/file.js) to the proper file (pub/static/frontend/path/to/file.js).



    Server running with Apache



    If you are running your website on apache, check if the rewrite module is enabled, and if not, enable it.



    Here are some steps to enable it (Magento 2 official documentation)




    Solution for the 404 error on pub/media/styles.css file specificaly



    Sample data are not used



    The pub/media/styles.css file is specificaly used with the sample data modules (which are generating the file).



    If you deployed the sample data at some point, you will have a value set in the design config which will try to load this file :




    Content > Design > Configuration > > HTML Head > Script and Style Sheets




    <link rel="stylesheet" type="text/css" media="all" href="MEDIA_URLstyles.css" />


    If you are not using sample data anymore, you can simply remove this line from the textarea, and save the theme.



    Sample data are used



    Here is the details of what could be happening



    To be short :



    • It can happen when you git clone your website from a repository on a new environment, as this file is ignored by default and won't be generated by a static deployment.

    • The solution is to manualy add the CSS code in your design configuration in the Magento back office.





    share|improve this answer



























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f153197%2fmagento-2-1-3-pub-media-styles-css-file-not-existed%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      You also need to run setup:di:compile and then give permission 777 (Which is not preferable on production mode).



      Run all the commands in below sequence :



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


      2. php bin/magento setup:di:compile run this command. It will generate
        var/generation and other directories again.


      3. sudo chmod 777 -R var pub pub/media app/etc (Give permissions to generated directories)


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

      5. php bin/magento cache:clean

      Refer this link for more details - After installation, I have problems with Magento 2



      It will resolved your issue.






      share|improve this answer



























      • I tried as you suggested but the styles.css file is still missing.

        – Tyler Bean
        Jan 5 '17 at 6:07











      • @TylerBean check this link - magento.stackexchange.com/questions/96289/….

        – Manthan Dave
        Jan 5 '17 at 6:17















      1














      You also need to run setup:di:compile and then give permission 777 (Which is not preferable on production mode).



      Run all the commands in below sequence :



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


      2. php bin/magento setup:di:compile run this command. It will generate
        var/generation and other directories again.


      3. sudo chmod 777 -R var pub pub/media app/etc (Give permissions to generated directories)


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

      5. php bin/magento cache:clean

      Refer this link for more details - After installation, I have problems with Magento 2



      It will resolved your issue.






      share|improve this answer



























      • I tried as you suggested but the styles.css file is still missing.

        – Tyler Bean
        Jan 5 '17 at 6:07











      • @TylerBean check this link - magento.stackexchange.com/questions/96289/….

        – Manthan Dave
        Jan 5 '17 at 6:17













      1












      1








      1







      You also need to run setup:di:compile and then give permission 777 (Which is not preferable on production mode).



      Run all the commands in below sequence :



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


      2. php bin/magento setup:di:compile run this command. It will generate
        var/generation and other directories again.


      3. sudo chmod 777 -R var pub pub/media app/etc (Give permissions to generated directories)


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

      5. php bin/magento cache:clean

      Refer this link for more details - After installation, I have problems with Magento 2



      It will resolved your issue.






      share|improve this answer















      You also need to run setup:di:compile and then give permission 777 (Which is not preferable on production mode).



      Run all the commands in below sequence :



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


      2. php bin/magento setup:di:compile run this command. It will generate
        var/generation and other directories again.


      3. sudo chmod 777 -R var pub pub/media app/etc (Give permissions to generated directories)


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

      5. php bin/magento cache:clean

      Refer this link for more details - After installation, I have problems with Magento 2



      It will resolved your issue.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Apr 13 '17 at 12:55









      Community

      1




      1










      answered Jan 5 '17 at 4:49









      Manthan DaveManthan Dave

      8,1242 gold badges17 silver badges42 bronze badges




      8,1242 gold badges17 silver badges42 bronze badges















      • I tried as you suggested but the styles.css file is still missing.

        – Tyler Bean
        Jan 5 '17 at 6:07











      • @TylerBean check this link - magento.stackexchange.com/questions/96289/….

        – Manthan Dave
        Jan 5 '17 at 6:17

















      • I tried as you suggested but the styles.css file is still missing.

        – Tyler Bean
        Jan 5 '17 at 6:07











      • @TylerBean check this link - magento.stackexchange.com/questions/96289/….

        – Manthan Dave
        Jan 5 '17 at 6:17
















      I tried as you suggested but the styles.css file is still missing.

      – Tyler Bean
      Jan 5 '17 at 6:07





      I tried as you suggested but the styles.css file is still missing.

      – Tyler Bean
      Jan 5 '17 at 6:07













      @TylerBean check this link - magento.stackexchange.com/questions/96289/….

      – Manthan Dave
      Jan 5 '17 at 6:17





      @TylerBean check this link - magento.stackexchange.com/questions/96289/….

      – Manthan Dave
      Jan 5 '17 at 6:17













      0














      In your Magento pub /static folder .htaccess file chnge so copy that in another folder and paste it
      It is working for you






      share|improve this answer





























        0














        In your Magento pub /static folder .htaccess file chnge so copy that in another folder and paste it
        It is working for you






        share|improve this answer



























          0












          0








          0







          In your Magento pub /static folder .htaccess file chnge so copy that in another folder and paste it
          It is working for you






          share|improve this answer













          In your Magento pub /static folder .htaccess file chnge so copy that in another folder and paste it
          It is working for you







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 5 '17 at 12:21









          Moin MalekMoin Malek

          5236 silver badges21 bronze badges




          5236 silver badges21 bronze badges
























              0














              You have deleted your .htaccess file from pub/static/.htaccess



              please unhide files on that folder if check if available, else copy it from another magento setup and copy - paste it on "pub/static/ HERE "



              then follow below commands.



              1. sudo chmod 777 -R var pub pub/media app/etc

              2. php bin/magento setup:static-content:deploy

              3. php bin/magento cache:clean

              Hope this will help you.






              share|improve this answer



























              • I checked and the .htaccess is still available on pub/static. I think it's not the problem. I downloaded zipped magento and copy the pub/media/styles.css from there to my project and it's working now. It's really hard to explain why the file is not created.

                – Tyler Bean
                Jan 5 '17 at 7:33











              • Great to hear your problem solved... :) @TylerBean

                – Yogesh
                Jan 5 '17 at 8:11












              • Thanks a lot. But it's still a mystery why the file is not created. :)

                – Tyler Bean
                Jan 5 '17 at 8:56















              0














              You have deleted your .htaccess file from pub/static/.htaccess



              please unhide files on that folder if check if available, else copy it from another magento setup and copy - paste it on "pub/static/ HERE "



              then follow below commands.



              1. sudo chmod 777 -R var pub pub/media app/etc

              2. php bin/magento setup:static-content:deploy

              3. php bin/magento cache:clean

              Hope this will help you.






              share|improve this answer



























              • I checked and the .htaccess is still available on pub/static. I think it's not the problem. I downloaded zipped magento and copy the pub/media/styles.css from there to my project and it's working now. It's really hard to explain why the file is not created.

                – Tyler Bean
                Jan 5 '17 at 7:33











              • Great to hear your problem solved... :) @TylerBean

                – Yogesh
                Jan 5 '17 at 8:11












              • Thanks a lot. But it's still a mystery why the file is not created. :)

                – Tyler Bean
                Jan 5 '17 at 8:56













              0












              0








              0







              You have deleted your .htaccess file from pub/static/.htaccess



              please unhide files on that folder if check if available, else copy it from another magento setup and copy - paste it on "pub/static/ HERE "



              then follow below commands.



              1. sudo chmod 777 -R var pub pub/media app/etc

              2. php bin/magento setup:static-content:deploy

              3. php bin/magento cache:clean

              Hope this will help you.






              share|improve this answer















              You have deleted your .htaccess file from pub/static/.htaccess



              please unhide files on that folder if check if available, else copy it from another magento setup and copy - paste it on "pub/static/ HERE "



              then follow below commands.



              1. sudo chmod 777 -R var pub pub/media app/etc

              2. php bin/magento setup:static-content:deploy

              3. php bin/magento cache:clean

              Hope this will help you.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jan 5 '17 at 12:27









              Devtype

              2,2951 gold badge14 silver badges33 bronze badges




              2,2951 gold badge14 silver badges33 bronze badges










              answered Jan 5 '17 at 6:17









              YogeshYogesh

              3522 silver badges11 bronze badges




              3522 silver badges11 bronze badges















              • I checked and the .htaccess is still available on pub/static. I think it's not the problem. I downloaded zipped magento and copy the pub/media/styles.css from there to my project and it's working now. It's really hard to explain why the file is not created.

                – Tyler Bean
                Jan 5 '17 at 7:33











              • Great to hear your problem solved... :) @TylerBean

                – Yogesh
                Jan 5 '17 at 8:11












              • Thanks a lot. But it's still a mystery why the file is not created. :)

                – Tyler Bean
                Jan 5 '17 at 8:56

















              • I checked and the .htaccess is still available on pub/static. I think it's not the problem. I downloaded zipped magento and copy the pub/media/styles.css from there to my project and it's working now. It's really hard to explain why the file is not created.

                – Tyler Bean
                Jan 5 '17 at 7:33











              • Great to hear your problem solved... :) @TylerBean

                – Yogesh
                Jan 5 '17 at 8:11












              • Thanks a lot. But it's still a mystery why the file is not created. :)

                – Tyler Bean
                Jan 5 '17 at 8:56
















              I checked and the .htaccess is still available on pub/static. I think it's not the problem. I downloaded zipped magento and copy the pub/media/styles.css from there to my project and it's working now. It's really hard to explain why the file is not created.

              – Tyler Bean
              Jan 5 '17 at 7:33





              I checked and the .htaccess is still available on pub/static. I think it's not the problem. I downloaded zipped magento and copy the pub/media/styles.css from there to my project and it's working now. It's really hard to explain why the file is not created.

              – Tyler Bean
              Jan 5 '17 at 7:33













              Great to hear your problem solved... :) @TylerBean

              – Yogesh
              Jan 5 '17 at 8:11






              Great to hear your problem solved... :) @TylerBean

              – Yogesh
              Jan 5 '17 at 8:11














              Thanks a lot. But it's still a mystery why the file is not created. :)

              – Tyler Bean
              Jan 5 '17 at 8:56





              Thanks a lot. But it's still a mystery why the file is not created. :)

              – Tyler Bean
              Jan 5 '17 at 8:56











              0














              There can be many explainations according to the informations provided.




              Solution for 404 errors on static files



              Files and folders permissions and/or ownership



              This is the most probable reason as we can also see 404 error on other static files. In that case you should physicaly see the file on the web server.



              You are running the command sudo chmod 777 -R var pub pub/media app/etc (which is a bad practice by the way, especially for the app/etc folder which contains sensitive data), your folders are still empty (you just ran a rm -rf on their content).



              When you deploy static files, the files and folders generated are not generated as 777.



              In most cases (following Magento files and folders permissions best practices), this shouldn't be a problem (and it's a normal behavior).



              But if you are running the commands using a different user than the user running your Magento application (ex. : using root for commands, and www-data for website), you could end up with permissions issues, because your Magento application may not be authorized to read the files from this different user (who could also be in a different group).



              In that case :



              • Fix user/group ownership if necessary : chown -R user:group /path/to/magento/

              • Use the same user than the web server user

                • In some case you are not able to log in as the web server user, you should then use a user in the same group

                • More details here (Magento 2 official documentation)


              Missing pub/static/.htaccess file



              This point is more about the other 404 errors on the static files, rather than the pub/media/styles.css file



              When changes are made on the design, static files are often purged (typicaly with a rm -rf pub/static/*).



              You may have accidentaly removed the pub/static/.htaccess file while doing so (with a manual purge for example).



              This file is mandatory for apache servers, as it will allow Magento to redirect the versioned URL (yoursite.local/static/someversion/frontend/path/to/file.js) to the proper file (pub/static/frontend/path/to/file.js).



              Server running with Apache



              If you are running your website on apache, check if the rewrite module is enabled, and if not, enable it.



              Here are some steps to enable it (Magento 2 official documentation)




              Solution for the 404 error on pub/media/styles.css file specificaly



              Sample data are not used



              The pub/media/styles.css file is specificaly used with the sample data modules (which are generating the file).



              If you deployed the sample data at some point, you will have a value set in the design config which will try to load this file :




              Content > Design > Configuration > > HTML Head > Script and Style Sheets




              <link rel="stylesheet" type="text/css" media="all" href="MEDIA_URLstyles.css" />


              If you are not using sample data anymore, you can simply remove this line from the textarea, and save the theme.



              Sample data are used



              Here is the details of what could be happening



              To be short :



              • It can happen when you git clone your website from a repository on a new environment, as this file is ignored by default and won't be generated by a static deployment.

              • The solution is to manualy add the CSS code in your design configuration in the Magento back office.





              share|improve this answer





























                0














                There can be many explainations according to the informations provided.




                Solution for 404 errors on static files



                Files and folders permissions and/or ownership



                This is the most probable reason as we can also see 404 error on other static files. In that case you should physicaly see the file on the web server.



                You are running the command sudo chmod 777 -R var pub pub/media app/etc (which is a bad practice by the way, especially for the app/etc folder which contains sensitive data), your folders are still empty (you just ran a rm -rf on their content).



                When you deploy static files, the files and folders generated are not generated as 777.



                In most cases (following Magento files and folders permissions best practices), this shouldn't be a problem (and it's a normal behavior).



                But if you are running the commands using a different user than the user running your Magento application (ex. : using root for commands, and www-data for website), you could end up with permissions issues, because your Magento application may not be authorized to read the files from this different user (who could also be in a different group).



                In that case :



                • Fix user/group ownership if necessary : chown -R user:group /path/to/magento/

                • Use the same user than the web server user

                  • In some case you are not able to log in as the web server user, you should then use a user in the same group

                  • More details here (Magento 2 official documentation)


                Missing pub/static/.htaccess file



                This point is more about the other 404 errors on the static files, rather than the pub/media/styles.css file



                When changes are made on the design, static files are often purged (typicaly with a rm -rf pub/static/*).



                You may have accidentaly removed the pub/static/.htaccess file while doing so (with a manual purge for example).



                This file is mandatory for apache servers, as it will allow Magento to redirect the versioned URL (yoursite.local/static/someversion/frontend/path/to/file.js) to the proper file (pub/static/frontend/path/to/file.js).



                Server running with Apache



                If you are running your website on apache, check if the rewrite module is enabled, and if not, enable it.



                Here are some steps to enable it (Magento 2 official documentation)




                Solution for the 404 error on pub/media/styles.css file specificaly



                Sample data are not used



                The pub/media/styles.css file is specificaly used with the sample data modules (which are generating the file).



                If you deployed the sample data at some point, you will have a value set in the design config which will try to load this file :




                Content > Design > Configuration > > HTML Head > Script and Style Sheets




                <link rel="stylesheet" type="text/css" media="all" href="MEDIA_URLstyles.css" />


                If you are not using sample data anymore, you can simply remove this line from the textarea, and save the theme.



                Sample data are used



                Here is the details of what could be happening



                To be short :



                • It can happen when you git clone your website from a repository on a new environment, as this file is ignored by default and won't be generated by a static deployment.

                • The solution is to manualy add the CSS code in your design configuration in the Magento back office.





                share|improve this answer



























                  0












                  0








                  0







                  There can be many explainations according to the informations provided.




                  Solution for 404 errors on static files



                  Files and folders permissions and/or ownership



                  This is the most probable reason as we can also see 404 error on other static files. In that case you should physicaly see the file on the web server.



                  You are running the command sudo chmod 777 -R var pub pub/media app/etc (which is a bad practice by the way, especially for the app/etc folder which contains sensitive data), your folders are still empty (you just ran a rm -rf on their content).



                  When you deploy static files, the files and folders generated are not generated as 777.



                  In most cases (following Magento files and folders permissions best practices), this shouldn't be a problem (and it's a normal behavior).



                  But if you are running the commands using a different user than the user running your Magento application (ex. : using root for commands, and www-data for website), you could end up with permissions issues, because your Magento application may not be authorized to read the files from this different user (who could also be in a different group).



                  In that case :



                  • Fix user/group ownership if necessary : chown -R user:group /path/to/magento/

                  • Use the same user than the web server user

                    • In some case you are not able to log in as the web server user, you should then use a user in the same group

                    • More details here (Magento 2 official documentation)


                  Missing pub/static/.htaccess file



                  This point is more about the other 404 errors on the static files, rather than the pub/media/styles.css file



                  When changes are made on the design, static files are often purged (typicaly with a rm -rf pub/static/*).



                  You may have accidentaly removed the pub/static/.htaccess file while doing so (with a manual purge for example).



                  This file is mandatory for apache servers, as it will allow Magento to redirect the versioned URL (yoursite.local/static/someversion/frontend/path/to/file.js) to the proper file (pub/static/frontend/path/to/file.js).



                  Server running with Apache



                  If you are running your website on apache, check if the rewrite module is enabled, and if not, enable it.



                  Here are some steps to enable it (Magento 2 official documentation)




                  Solution for the 404 error on pub/media/styles.css file specificaly



                  Sample data are not used



                  The pub/media/styles.css file is specificaly used with the sample data modules (which are generating the file).



                  If you deployed the sample data at some point, you will have a value set in the design config which will try to load this file :




                  Content > Design > Configuration > > HTML Head > Script and Style Sheets




                  <link rel="stylesheet" type="text/css" media="all" href="MEDIA_URLstyles.css" />


                  If you are not using sample data anymore, you can simply remove this line from the textarea, and save the theme.



                  Sample data are used



                  Here is the details of what could be happening



                  To be short :



                  • It can happen when you git clone your website from a repository on a new environment, as this file is ignored by default and won't be generated by a static deployment.

                  • The solution is to manualy add the CSS code in your design configuration in the Magento back office.





                  share|improve this answer













                  There can be many explainations according to the informations provided.




                  Solution for 404 errors on static files



                  Files and folders permissions and/or ownership



                  This is the most probable reason as we can also see 404 error on other static files. In that case you should physicaly see the file on the web server.



                  You are running the command sudo chmod 777 -R var pub pub/media app/etc (which is a bad practice by the way, especially for the app/etc folder which contains sensitive data), your folders are still empty (you just ran a rm -rf on their content).



                  When you deploy static files, the files and folders generated are not generated as 777.



                  In most cases (following Magento files and folders permissions best practices), this shouldn't be a problem (and it's a normal behavior).



                  But if you are running the commands using a different user than the user running your Magento application (ex. : using root for commands, and www-data for website), you could end up with permissions issues, because your Magento application may not be authorized to read the files from this different user (who could also be in a different group).



                  In that case :



                  • Fix user/group ownership if necessary : chown -R user:group /path/to/magento/

                  • Use the same user than the web server user

                    • In some case you are not able to log in as the web server user, you should then use a user in the same group

                    • More details here (Magento 2 official documentation)


                  Missing pub/static/.htaccess file



                  This point is more about the other 404 errors on the static files, rather than the pub/media/styles.css file



                  When changes are made on the design, static files are often purged (typicaly with a rm -rf pub/static/*).



                  You may have accidentaly removed the pub/static/.htaccess file while doing so (with a manual purge for example).



                  This file is mandatory for apache servers, as it will allow Magento to redirect the versioned URL (yoursite.local/static/someversion/frontend/path/to/file.js) to the proper file (pub/static/frontend/path/to/file.js).



                  Server running with Apache



                  If you are running your website on apache, check if the rewrite module is enabled, and if not, enable it.



                  Here are some steps to enable it (Magento 2 official documentation)




                  Solution for the 404 error on pub/media/styles.css file specificaly



                  Sample data are not used



                  The pub/media/styles.css file is specificaly used with the sample data modules (which are generating the file).



                  If you deployed the sample data at some point, you will have a value set in the design config which will try to load this file :




                  Content > Design > Configuration > > HTML Head > Script and Style Sheets




                  <link rel="stylesheet" type="text/css" media="all" href="MEDIA_URLstyles.css" />


                  If you are not using sample data anymore, you can simply remove this line from the textarea, and save the theme.



                  Sample data are used



                  Here is the details of what could be happening



                  To be short :



                  • It can happen when you git clone your website from a repository on a new environment, as this file is ignored by default and won't be generated by a static deployment.

                  • The solution is to manualy add the CSS code in your design configuration in the Magento back office.






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 1 at 12:30









                  CladiussCladiuss

                  3394 silver badges12 bronze badges




                  3394 silver badges12 bronze badges






























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f153197%2fmagento-2-1-3-pub-media-styles-css-file-not-existed%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                      Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                      Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?