Friday, August 4, 2017

Awesome Local Domain in XAMPP


Have you ever tried to do a local domain before? For developers out there who really wanted to change their development environment from "http://localhost/myproject" to "http://myproject.dev", well here is the trick on how to do this in you local server using XAMPP in WINDOWS.




As a matter of course XAMPP sets up every one of the destinations you make to have http://localhost as its top level domain, and giving your site http://localhost/site as the url unless you introduce your site in the top level folder. Yet, what happens when you have various sites or you need to try out situations which would expect you to have diverse areas, well I am will show you to do only that.

So here's the steps on what we need to in order to achieve a local domain:

1. You need to install XAMPP in your device.
2. Take note, don't start the APACHE first in XAMPP Control Panel.
3. Locate the directory C:/xampp/apache/conf/extra or choose the directory where you installed the XAMPP
4. Open httpd-vhosts.conf which will be found in C:/xampp/apache/conf/extra or in the specified directory where XAMPP is installed. Take note, you will need to open httpd-vhosts.conf using administrative privilege for you to be able to save the changes on it. 
5. At the very bottom of the file, insert this configurations below:
NameVirtualHost *:80

DocumentRoot "C:/xampp/htdocs"
ServerName localhost


The code gives you access to the default htdocs directory. Without that, http://localhost/ will be inaccessible. 


1. Now, you will need to copy the code below and paste it on httpd-vhosts.conf.

DocumentRoot "C:/xampp/htdocs/myproject"
ServerName myproject.dev
ServerAlias www.myproject.dev

Order allow,deny
Allow from all


#Change wherever you see test site to the location of your site and the domain name you might want to utilize, the most well-known ones are .dev, .loc and .neighborhood (I think anything with the exception of the conventional .com/.net domains would work fine … however don't cite me on it)

2. Presently we go to our Windows Hosts File, to alter the HOSTS. the record will be situated at C:/Windows/System32/drivers/and so on/hosts, where hosts is the document.
127.0.0.1             localhost
127.0.0.1             www.myproject1.dev
127.0.0.1             www.myproject2.dev
127.0.0.1             demo.myproject3.dev
127.0.0.1             demo.myproject4.dev


As you can see on the code above, that is the format for for host configuration.

Just simply copy it and you're good to go. But take note, if you are having problem on saving it, you probably didn't open your text editor as administrator privilege mode.

Then lastly, start your Apache in XAMPP Control Panel. Well that's it! Easy right?

If this article helps you, feel free to share this article and I would really appreciate it!








No comments:

Post a Comment

PHP IMAP - Get Emails from GMAIL

Fetching emails from your GMIAL account is easier than what you expected. With the use of PHP IMAP Extension, you can easily fetch your e...