Jump to content

Localhost and subdomains


Carsten

Recommended Posts

I have installed Apache and the localhost works fine. I'm pretty blank when it comes to complex system settings, so please post any answers with fool-proof logic :)

 

Now I need 2 things:

 

1. Changing my main localhost root folder from c:\apache\htdoc\north to c:\apache\htdoc. Is it enough to edit the httpd.conf file to contain:

DocumentRoot "C:/apache/htdocs", or are there other files needed to change?

 

2. Being able to access different websites on my home computer, using subdirectories like c:/apache/htdocs/north and C:/apache/htdocs/south etc. I've tried everything I could imagine and all I get is the infamous and sickening 404 finger!

 

Please help

 

P.S. I'm using Dreamweaver 2004. If there are special considerations, do enlight me.

 

Carsten

 

 

Link to comment
Share on other sites

Yes there is a way and I've found it (I don't usually speak to myself!)

 

Here is the layout.

 

In the httpd.conf file, at the very buttom right before these 2 last lines

 

LoadModule php4_module c:/php/sapi/php4apache.dll

AddType application/x-httpd-php .php

 

place this:

 

NameVirtualHost 127.0.0.1
Listen 127.0.0.1:80

<VirtualHost 127.0.0.1>  
ServerName main.com
ServerAlias main
DocumentRoot C:/apache/htdocs
</VirtualHost>

<VirtualHost 127.0.0.1>
ServerName website_1.com
ServerAlias website_2
DocumentRoot C:/apache/htdocs/website_1
</VirtualHost>

<VirtualHost 127.0.0.1>
ServerName website_2.com
ServerAlias website_2
DocumentRoot C:/apache/htdocs/website_2
</VirtualHost>

 

The first of the three sections must be present before the others, as this sets up the root of the localhost (I guess). The others can just be multiplied for as many times as you have websites in need of care.

 

Remember to stop Apache, and then restart it, for the changes to take effect.

 

And last, for the ones using Dreamweaver:

 

For each new site, set Site Definition like this:

 

Server model: PHP MySQL

Access: Local/Network

Testing Server Folder: C:\apache\htdocs\website_1\

URL prefix: http://localhost/website_1/

 

Hope somebody else can have good use of this. It took me about 10 hours of research and too many cigarettes, but that is all behind me now. I'm a happy man.

 

Carsten

 

 

Link to comment
Share on other sites

Guest footballkid4

By using the IP: 127.0.0.1 you are enclosing yourself to localhost access only. Other users who attempt to access your computer won't be able to use the subdomains

Link to comment
Share on other sites

By using the IP: 127.0.0.1 you are enclosing yourself to localhost access only. Other users who attempt to access your computer won't be able to use the subdomains

 

Yes you're right, and that was also the idea. I'm not running a server myself, and I don't want anyone to access my computer. I just wanted a setup, so I could locally maintain different websites, and then easily upload the from Dreamweaver.

 

If there is a catch in that aspect, do let me know.

 

Carsten

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.