If you are running the Apache Web server using a DSL or a faster
broadband internet, you can provide hosting services to others. You can
even host their domains on your server, without the need of different
IP for each domain. This is called virtual hosting, and the best part
to know is, how easy it is to setup.
DNS:
You will need a DNS and if you don’t have one, you will need to contact
your hosting provider to add a new domain to the DNS server. But if you
have your own DNS Sever you must do this :
- Edit Bind or NameD or DNS to add the new domain name to it
- Point it to the IP of your virtual hosting server [127.0.0.1 in the below example]
- Restart your DNS service
Configure Apache :
Download Apache and beging with the configuration :
Start > Programs > Apache HTTP Server > Configure Apache
Server > Edit httpd.conf which is the Apache Configuration File.
If Apache doesn’t appear in your start menu, edit it from here : C:Program FilesApache GroupApacheconfhttpd.conf
There will be a line like this one :
#Include conf/extra/httpd-vhosts.conf
From the above line remove ‘#’ from the start so it looks like this :
Include conf/extra/httpd-vhosts.conf
This is to enable virtual host support.
Everything else is pre-configured in httpd-vhosts.conf file.
Now go to the bottom of the file and add the following code :
NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> DocumentRoot "C:WebsitesWSite1" ServerName solorulez.local </VirtualHost> <VirtualHost 127.0.0.1> DocumentRoot "C:WebsitesWSite2" ServerName solomon.local </VirtualHost>
Now save the file. This is the only configuration we need to do.
Now if you type your web address in your browser you can open it, but
not everyone on the internet will be access it. So now you need to
setup DNS. To do this you will need to edit hosts file on your
computer. This file has no extension. This file is located at : "C:Windowssystem32driversetchosts" or "C:WINNTsystem32driversetchosts". Open this file in any text editor and add the following lines at the bottom of the file :
127.0.0.1 solorulez.local 127.0.0.1 solomon.local
Save the file and close it.
Restart the Apache server so that the changes could take effect :
Click Start > Programs > Apache HTTP Server > Control Apache Server > Restart
or run the following command :
apache -w -n "Apache" -k restart
Thats it… Now go around and test your websites…