How To Create XAMPP Virtual Host For Domain !!

25 03 2009
www

Virtual Host For Domain

In this post, I will explain how to create apache virtual host.

Virtual host is apache feature to allow us to make our website with it own domain in our computer . So we can access our website through “real” url. yes !!

so , we will make a virtual host for www.yourname.com domain. you can use .org – .com – .net …etc

mmmmm…… next steps

1 // open your terminal .. and return :)

If you installing lampp in /opt you need, you must be root  to edit /opt/lampp/etc/httpd.conf file. ok

2 // Use

sudo gedit /opt/lampp/etc/httpd.conf

3 // And add this line in the last file:

include /home/username/website/extra-httpd.conf

save and close ok……

4 // now..

Open your text editor

And add these lines

<VirtualHost 127.0.2.1>
ServerName www.yourname.com
DocumentRoot /home/username/website/www.yourname.com

<Directory /home/username/website/www.yourname.com>
AllowOverride All
Options All
</Directory>
</VirtualHost>


Save this file as extra-httpd.conf in /home/username/website, as we define in httpd.conf file. ok

5 // add host :

Then, we must add the IP address we use above to /etc/hosts file.

add : ip > 127.0.2.1 and domain www.yourname.com

6 // if you have ubuntu

Go to System >> Administration >> Network.
Change to the tab to Hosts, and  click Add,  enter the IP address and the server name.