How to Configure Apache to use Virtual Hosts

Using Apache is Good, but for one website is limiting its potential you can create multiple websites, domains and sub-domains with Apache, see below.

 

 

First you need to stop your server, you can do this on lunix by entering
[box type=”shadow”] $ sudo /etc/init.d/apache2 stop [/box]

into your terminal, this allows you to make changes to files in your server without breaking it, for windows you need to stop Apache using Xammp, see below.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now Enable Mod_log_config browse here

[box type=”shadow”]xamppapacheconf[/box]

and in httpd.conf remove the # from this line

[box type=”shadow”]#LoadModule log_config_module modules/mod_log_config.so[/box]

to look like this

[box type=”shadow”]LoadModule log_config_module modules/mod_log_config.so[/box]

 

next using an FTP program or other method, go to your website’s root directory such as

[box type=”shadow”]/home/*/public_html/cgi-bin/[/box]

 

Or for windows

[box type=”shadow”]C:xampphtdocs[/box]

This is the base of your web server, and probably where your Index.html is located, create two folders, Domains and Subdomains, this is where your domains will be stored. See below

Domains, Subdomains

 

 

 

 

 

 

 

In Domains, Place the dome of your website, replacing dots with hyphens like so

Domains, if

 

 

 

(Also add any other websites that you plan to host on the server)

Then copy the data that was in your root of the server into the domain folder on the server like this

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

then paste  into your domain folder like this

 

Paste

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

So your Server should now have the ‘root’ of the server in

[box type=”shadow”]WEBROOTDomainsinfinityflame-co-ukindex.html[/box]

or subsequent folders in Linux.

now you need to redirect traffic from your website to the correct folder, this is done with virtual Hosts’s, and is also how you add sub domains see below

browse to your Apache installation folder and go to httpd-vhosts.conf

[box type=”shadow”]apacheconfextrahttpd-vhosts.conf[/box]

 

and at the bottom add the following code replaceing my domain, with yours.

now test the website, start Apache and browse to your domain, you should see your site as you did before, you have now configured your website to use Virtual Hosts

now you need to add other domains and subdomains, See Here