Magento 2 comes with two index.php files where one file is inside root folder and another one is inside /pub folder. Magento 2 offers to run your application using any one of this file. If you choose to run your application using /pub/index.php then it is a good decision for security point of view as it restrict unauthorized direct access of application files.
Here i will show you how to configure Magento 2 in localhost using pub/index.php file by creating virtualhost. You can do the same by following below steps after installing Magento 2.
- Open httpd-vhosts.conf file of apache server. You wll find this file at “D:\xampp\apache\conf\extra” location.
- Create virtual host by adding below code in httpd-vhosts.conf file.
- Save httpd-vhosts.conf file and restart apache server.
- Open C:\Windows\System32\drivers\etc\hosts file and add your server Name entry as like below.
- Open your Magento 2 database table “core_config_data“. Update value for path “web/unsecure/base_url” and “web/secure/base_url” to “http://local.magento2.com/“.
- Open web browser and hit URL: “http://local.magento2.com” for frontend and “http://local.magento2.com/admin” for backend.
Now your application is running using pub/index.php file.