logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: DocumentRoot and localhost vs 127.0.0.1 (Sorry, it's long)
Author
RogerH



Joined: 28 Sep 2012
Posts: 1
Location: USA, Pfeifer

PostPosted: Fri 28 Sep '12 14:28    Post subject: DocumentRoot and localhost vs 127.0.0.1 (Sorry, it's long) Reply with quote

I have searched and fiddled and restarted far too many times, and have decided to come and hopefully get my problem resolved with help from those more knowledgable.

First, a quick overview of my setup. I have installed Apache 2.2.x, PHP 4.3.x, and MySQL on my local Windows 7 machine. Everything works, and have been using it for a few weeks now. I am currently have 3 sites I am working on:

mysite: main website that is currenlty online

mysitedev: revamping our main website, and don't want to mix it with what is live

mysite2: small side project site

I started with just mysitedev in the htdoc folder, it uses a shopping cart tied is to the domain name, so to test it locally I have to edit the .hosts file to actually preview it, but all worked fine.

I recently needed to do some minor updating to our current site, but didn't want to do live testing of it, so I created a second folder (mysite) for our current site, and renamed the development site folder to mysitedev. Since both the use the same shopping cart, both require access through www.domain.com. At first I attempted using a virtual host, thinking maybe I could do domain.com for one and www.domain.com for the other, but no luck. It may be possible, but was having general issues with my configuration that wouldn't let Apache start so decided to skip it. Any suggestions on this are welcome, but not too worried about it.

I then moved on to changing DocumentRoot (and the <Directory...> section to the appropriate folder. At first I directed it to my side site folder (site2) and going to localhost in a browser brought it up fine.

Trying out my main site (mysite) and using www.domain.com (redirected to 127.0.0.1 through .hosts file) would bring up a "No index found" error or something similar. Looking in my error log I found out it was serving from htdoc, which was no longer there. Creating an htdocs folder and putting a dummy index.php file in there caused www.mydomain.com to pull up the index file in htdocs instead of mysite like it should according to the DocumentRoot setting.

After a while of searching and changing and generally acomplishing nothing, I somehow tried going straight to localhost in my browser and lo and behold it worked! Well, not really, as the shopping cart software just threw an error - domain not authorized, but it did prove that 127.0.0.1 is serving htdocs while localhost is serving mysite.

TL;DR -
Windows 7 with Apache 2.2, PHP 4.3, and MySQL 5.
Changed DocumentRoot to mysite folder
127.0.0.1 serves htdocs folder anyway (www.domain.com redirected through .hosts file)
localhost servers correct (mysite) folder

Looking for a resolution as I have 2 versions of mysite that I am working on and they require domain name validation. I am currently using the htdocs folder and using mklink to link to the appropriate folder, but it's a pain.

Thanks!
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Tue 02 Oct '12 17:21    Post subject: Reply with quote

if you can than run the vhost ip based. So in your hosts file on can define the IP to the dev system and the external users will see the other page because of the external DNS server.
Back to top


Reply to topic   Topic: DocumentRoot and localhost vs 127.0.0.1 (Sorry, it's long) View previous topic :: View next topic
Post new topic   Forum Index -> Apache