cancel
Showing results for 
Search instead for 
Did you mean: 

404 error for css and js after install

Re: 404 error for css and js after install

Nobody can solve this error? I have the same trouble.

Re: 404 error for css and js after install

Having the exact same problem the install completes fine but the css files will not load. 

Re: 404 error for css and js after install

Its permissions related Magento 2 creates folders with a permission of 770 and files with 660.

 

This is also the cause for images not showing and for the eternally spinning save in admin.

 

You can re-set the folder permissions to something that works on your server/hosting and  they will be saved and shown...

 

BUT the next time you reset the cache you will have the same issue again.

 

Since the Magento 2 create folder/files permissions don't work on many servers, they should be changed in the official version to something more universal or something added so that its possible to change them during install to what is usable on the server/hosting it's installed on.

Re: 404 error for css and js after install

I can confirm the default permissions seem to be the problem. After resetting all permissions to the default required for files by my web host ( 0755 and 0644 ) magento loads find. However anytime I add a product or make a change that requires magento to write new files to the server the new files are not accessible until I change their permissions. So as a workaround until magento fixes this does anyone know which file to modify to change the default permissions assigned to files magento creates? 

Re: 404 error for css and js after install

Ok here's a fix that works on my server. To stop the files from going back to the wrong permissions every time a change is made open this file and change the permissions to whatever your webserver requires. 

 

vendor/magento/framework/Filesystem/DriverInterface.php

 

In my case setting the permissions in this file on line 20 to 0755 and line 25 to 644 seems to have corrected the problem. 

 

Hope this helps someone and I hope magento fixes this. 

Re: 404 error for css and js after install

Worked 100% SUCCESS! Thank you!

Re: 404 error for css and js after install

THANK YOU!!! mikefifield

 

You saved my weekend.

 

Changing Files permissions in the driverInterface.php file did the trick.

Re: 404 error for css and js after install

Hi,

I also have the 404 error on css and javascripts.

http://anyequip-prod.ap-southeast-2.elasticbeanstalk.com/anyequip/site/

 

I followed the deployment guide below and now production is off because of the 404 error

https://www.c3media.co.uk/blog/magento/deploying-magento-2-production-environment/#stepbystep

 

I tried to modify the permission in DriverInterface.php but no luck.

Any help will be appreciated.