Please follow the steps below to get rid of this issues.
1) Download the Magento 2.
2) Extract this in your www OR htdocs directory.
3) Install the magento. Do not use localhost, use 127.0.0.1 in store url and admin url.
4) After successful installation DO NOT RUN MAGENTO.
5) Now delete the cache / session of magento 2. Go to the below mentioned paths and delete the files.
Magento Root > var > cache > Delete all files
Magento Root > var > page_cache > Delete all files
Magento Root > var > session > Delete all files
6) Change the behavior of symlinks for some static resources as mentioned below:-
When Magento 2 is not in production mode, it will try to create symlinks for some static resources on local server. We have to change that behavior of Magento 2 by going to edit ROOT > app > etc > di.xml
file. Open up di.xml in your favorite code editor, find the virtualType name="developerMaterialization"
section. In that section below, you will find an item <item name="view_preprocessed" xsi:type="object">
which needs to be modified. You can modify it by changing the following content:
Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink
To:
Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
7) Delete all the files except **.htaccess**
Magento Root > pub > static > Delete all files except **.htaccess**
ITS DONE. Now you may run the magento Front and Backend URL