- Code: Select all
# httpd-vhosts.conf file Start
# Virtual Hosts
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
# Please see the documentation at http://httpd.apache.org/docs/2.2/vhosts/
# for further details before you try to setup virtual hosts.
# Use name-based virtual hosting.
#NameVirtualHost *:80
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
##<VirtualHost *:80>
## ServerAdmin webmaster@dummy-host/site-2.mail.w4vy.co.uk
## DocumentRoot "X:/xampp/apache/htdocs/dummy-host/site-2.w4vy.co.uk"
## ServerName dummy-host/site-2.w4vy.co.uk
## ErrorLog "logs/dummy-host/site-2.w4vy.co.uk-error.log"
## CustomLog "logs/dummy-host/site-2.w4vy.co.uk-access.log" common
##</VirtualHost>
# Virtual Hosts httpd-vhosts.conf file End
## ^^^Everything above here including this line can be deleted if you wish to make it tidy.^^^
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "X:/xampp/htdocs"
</VirtualHost>
<VirtualHost *:80>
ServerName d-and-b-computer-services.linkpc.net
ServerAlias www.d-and-b-computer-services.linkpc.net
ServerAdmin webmaster@d-and-b-computer-services.linkpc.net
DocumentRoot "X:/xampp/htdocs2"
<Directory "X:/xampp/htdocs2" >
Options Indexes +FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "logs/d-and-b-computer-services.linkpc.net-error.log"
CustomLog "logs/d-and-b-computer-services.linkpc.net-access.log" common
</VirtualHost>
The localhost path is to your default Apache htdocs folder - change it to your own default Apache htdocs folder.
The DocumentRoot for your vhost ServerName d-and-b-computer-services.linkpc.net can be any folder on your PC.
You may want to abbreviate the log file names for convenience.
Indenting is not required. left align just makes it easier for editing.
Save the file and restart Apache.
If the domain is registered then make sure it points to your ISP provided IP number at your domain name registrar or dynamic IP service if you are accessing the server from the Internet and make sure at least port 80 is forwarded and open.
Make sure your ISP does not block port 80.
For local access then you need to add this to your
C:\Windows\system32\drivers\etc\HOSTS file:
127.0.0.1 d-and-b-computer-services.linkpc.netand add your network IP also if required for example
192.0.0.10 d-and-b-computer-services.linkpc.netYou should be able to test it locally after editing the hosts file by going to
http://d-and-b-computer-services.linkpc.netin your browser and seeing your website that is in the xampp\htdocs2 folder.
You should also be able to go to
http://localhost and see the XAMPP Welcome Page that is in the xampp\htdocs folder.
If the above works then simply add another virtualhost in the format above if the DocumentRoot is outside of the default Apache htdocs folder.