This article describes the possible reasons and solutions for the issue where stylesheets and images do not load after installing Magento.
Affected products and versions
- Magento Commerce 2.2.x, 2.3.x
- Magento Open Source 2.2.x, 2.3.x
Steps to reproduce
- Install Magento.
- Navigate to the storefront or Admin.
Styles are applied, no UI element looks like missing styles.
Styles are not applied correctly, graphics is missing.
The path to images and stylesheets is not correct, either because of an incorrect base URL or because server rewrites (CentOS, Ubuntu) are not set up properly.
To confirm this is the case, use a web browser inspector to check the paths to static assets and verify those assets are located on the Magento file system.
Magento static assets are located under
<magento_root>/pub/static/ , within the
The following are possible solutions depending on the software you use and the cause of the problem:
- If you are using the Apache web server, verify your server rewrites setting and your Magento server's base URL and try again. If you set up the Apache
AllowOverridedirective incorrectly, the static files are not served from the correct location.
- If you are using the nginx web server, be sure to configure a virtual host file . The nginx virtual host file must meet the following criteria:
includedirective must point to the sample nginx configuration file in your Magento installation directory. For example:
bash include /var/www/html/magento2/nginx.conf.sample;
server_namedirective must match the base URL you specified when installing Magento. For example:
bash server_name 126.96.36.199;
- If the Magento application is in production mode , try deploying static view files using the command magento setup:static-content:deploy .