Welcome to WebmasterWorld Guest from 54.166.178.177

Forum Moderators: travelin cat

Message Too Old, No Replies

Having a lot of trouble setting up local dev server

hosts file is my current problem

     
6:49 pm on Oct 9, 2010 (gmt 0)

5+ Year Member



Hi

I (or rather a girl I really like) is trying to set up a local dev server on her mac. I have XAMPP installed and working. I then downloaded her current site to the local machine and can get the homepage up on localhost/thesite. I was then trying to edit the hosts file to redirect all links from http://www.example.com to localhost/thesite so that she can develop the site locally and then upload when complete (she has a really slow internet connection).

If I add the line:
127.0.0.1 www.example.com
to the hosts file and then go to www.example.com on a browser I get the XAMPP hompage. That makes sense. But since the local site is really located in localhost/thesite I instead tried:

127.0.0.1/thesite www.example.com
&
localhost/thesite www.example.com

neither of which worked. it just gave me the XAMPP homepage again when I went to www.example.com in my browser.

When I put the whole site into the root web folder in XAMPP and went to localhost it seemed to go straight to the online page (www.example.com)

any help would be appreciated.

[edited by: travelin_cat at 8:51 pm (utc) on Oct 9, 2010]
[edit reason] Changed example URL to example.com [/edit]

5:02 am on Oct 10, 2010 (gmt 0)

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Getting the requests to the right location is a two way process. First of all you have to map the domain name to the IP address. This is done with your first example line:

127.0.0.1 www.example.com

You then have to tell the Apache webserver that the documents start at the directory /thesite. You can't do this in the hosts file because that file is only used for the translation of IP addresses and domain names. You have to edit the Apache configuration file called httpd.conf and make your changes there.

In the httpd.conf file you will find a DocumentRoot tag. If you change the directory following it to the directory where you have placed your file, it should work. Be sure that the directory tree where the development files are is readable by Apache. It has to readable both on the operating system level, and with the correct Allow/Deny statements in the httpd.conf.

If you can't get the permissions right, it may be better to move the development files to the location which was originally mentioned in the DocumentRoot setting in the httpd.conf. That location should be readable by Apache.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month