Setting up (Apache) Localhost subdomains

This took me ages to work out – I found most online tutroials were vague and/or referenced different files than what is found in my MoWeS installation.

I have setup a local testing domain for CAMD: camd.loc
I wanted to run a WP Multisite install with subdomains such as: members.camd.loc

Anyway – this is what got the job done:

I needed to edit this file: H:apache2confhttpd.conf

Way way way down in the the vHost section around line 950.

I uncommented the line:
NameVirtualHost *:80

And I added the following to sections:

<pre><VirtualHost *:80>
ServerName localhost
DocumentRoot /www
</VirtualHost>

<VirtualHost *:80>
ServerName camd.loc
ServerAlias camd.loc *.camd.loc
DocumentRoot /www/camd
</VirtualHost></pre>

Note: you would keep adding additional blocks of code for each unique url you would like to use locally.

To make everything work you must add records for each url you have created to the ‘hosts’ file. In windows 7 the ‘hosts’ file is located here:
C:WindowsSystem32driversetc

These are lines that were added to the ‘hosts’ file:

<pre>127.0.0.1 localhost
127.0.0.1 camd.loc
127.0.0.1 members.camd.loc</pre>

Remember to restart your server after these changes have been made!

Revisions

There are no revisions for this post.

Tags: , , , , ,

No comments yet.

Leave a Reply