Jump to content


Photo

Localhost and subdomains


  • Please log in to reply
4 replies to this topic

#1 Carsten

Carsten
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 06 November 2005 - 12:06 AM

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



#2 Carsten

Carsten
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 06 November 2005 - 12:55 AM

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



#3 Guest_footballkid4_*

Guest_footballkid4_*
  • Guests

Posted 06 November 2005 - 01:34 AM

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

#4 Carsten

Carsten
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 06 November 2005 - 02:46 AM

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



#5 Guest_footballkid4_*

Guest_footballkid4_*
  • Guests

Posted 06 November 2005 - 10:09 PM

Nope :). Of course, insetad of loading your PC up with Apache and PHP and scuh, if you were just going to do localhost you could have download EasyPHP from:
http://www.easyphp.org
Does the same thing :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users