How to fix broken magento 2 issue for website?

How to fix broken magento 2 issue for website?

While going through the process of installation and running Magento 2, you may face some issues like 404 responses, admin URL broken, CSS being not linked, etc. At the time you check the console of the browser, you will see the errors referring to the attempts for accessing files which are missing or not found in the static/pub folder in Magento 2. Hopefully, the guide will solve these installation issues for broken Magento 2.
error page.JPG

Step 1: Enabling Apache Rewriting
First and foremost of all, have a look if you’ve enabled the server to rewrite for Apache or not. You’ll have to enable that if you did not earlier. In case you’re a user of Linux, just follow the following steps:

Switch to terminal. You will have to type there this:
sudo a2enmod rewrite
After you have done that, you must be restarting this Apache service for the changes to be applied. To restart the service, type this:
sudo service apache2 restart
Also, in this very case, you can ask the hosting provider for assistance.

Step 2: Fix Permissions for folders & files
Permissions and ownership can also arise a problem. This is necessary that you apply for proper permissions for all the folders and files of the Magento 2. Kindly read the official DevDoc to know and learn more about permissions for Magento 2 folders and files. Here is the link to follow for that:

Step 3: Delete the Sessions, Caches and Generated files
In this important step, we will delete previously generated sessions, caches, and old files. For deleting sessions and caches, you will have to navigate through these following paths, and then delete everything there.
MAGENTO2_ROOT > var > cache > *DELETE ALL*
MAGENTO2_ROOT > var > page_cache > *DELETE ALL*
MAGENTO2_ROOT > var > session > *DELETE ALL*
MAGENTO2_ROOT > var > view_preprocessed > *DELETE ALL*
More to that, you will have to remove everything there including the static files that are old generated. Do that from the below-mentioned path except for .htaccess. Here it is-
Step 4: Deploy the Static View Files
This mentioned ‘static view files’ indicates the files that are not dynamically generated. That also includes CSS files or images. You will find these files in this directory of the Magento 2 of yours, as they are located there: pub/static

Some of the files are cached as well in this directory: var/view_preprocessed

The mentioned ‘static view files’ need to be written down in the file system of Magento 2 using the CLI (Command-Line-Interface). To deploy them, run this command in the root directory of Magento 2:

php bin/magento setup:static-content:deploy
Step 5: Reindexing the Indexer
The Magento indexer converts the available data in Magento so that improvement of the performance is possible for storefront. Since the available data alters, the converted data has to be reindexed, that is to say updated. To reindex it in the Magento 2, just run this command below:

php bin/magento indexer:reindex
To sum up

Before you think to install Magento 2 and run it afterward, you should keep in mind that it is still under the process of developing. Magento is still working and they are working hard without any doubt to make the platform an ideal solution, almost for every person.
First release
Last update
0.00 star(s) 0 ratings