Create Local VirtualHost For Your Development Environment
If you are using xampp, you can access your local server just by go to http://localhost. So now i would like to share to you how to create your own local domain and add your local domain into apache virtual host, so you can have your local website for development purpose. For example you can have www.domain.local. To create this you only need to edit your apache vhost and your hosts file.
If you are using Windows you can edit your hosts files in C:\Windows\System32\drivers\etc\hosts, you can edit this file using Notepad with administrator rights ( Run as Administrator ). In this file you can add your local domain, see the example below:
127.0.0.1 www.ivankristianto.local 127.0.0.1 ivankristianto.local
After your create that and save the file you need to flush your dns, you can use the following command from your command prompt:
To test if your setting is working you can ping to your new local domain, it should have replied from ip 127.0.0.1.
After you edit your hosts file, now you need to create your virtual host in apache. If you are using Xampp for Windows, usually it is in [your xampp folder]\apache\conf\extra\httpd-vhosts.conf.
Please add this template and change it as necessary to match your configuration:
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "/path/to/htdocs/ivankristianto" ServerName www.ivankristianto.local <directory "="" path="" to="" <span="" class="hiddenSpellError" pre="">htdocs/ivankristianto"> Options Indexes FollowSymLinks MultiViews AllowOverride all Require all granted </Directory> </VirtualHost>
Please see the path carefully and make sure it is match your application folder path. If you are doing it right, now you can restart your apache, and open your browser to go to www.ivankristianto.local, it will show your website. With this technique you can do the development easier.