# Gentoo as a development webserver

## mycah

I am a self employed web developer.  My business is growing rapidly and I need to make some changes in how I do things.  Currently, my sites are all remotely hosted and I work on a winxp machine (need apps) and FTP my files to the server.

The time has come for me to setup a development server for my work.  I have not touched linux in 6 or 7 years (slackware) except for the minor telnet to a redhat machine.

Currently, I have 2 workstations behind a linksys router.  I would like to add a file/webserver to that mix.  What I would ideally like is to build the server and configure it exactly like the remote dedicated server I use to host production sites.  I also plan to use it as a minor file server.

I have a pretty good idea of the list of services I need to run.  The one thing I am having trouble with is how to best configure Apache.

I have never setup a DNS server.

Lets say I have 4 sites on my remote productions server.

www.example1.com

www.example2.com

www.example3.com

www.example4.com

What would be the best way to configure my server so I could mimic those domain names?  Is this even possible?  I basically want a development server that acts and functions just like my remote server.  I would like to be able to browse my local development server using those identical domain names.  Is that possible? Or at least browse it using IPs if I must...but have it set so I dont have to change my code on all the pages that are not relative links.

Any ideas?

Btw I am planning on using Gentoo on the development server.  I am also hoping to make a duplicate of the development server on a laptop so I can take it on the road to work with.

thanks

mycah

----------

## proxy

well on the development boxes you can mess with the /etc/hosts file so that the domain names resolve to there IPs not the real ones...

i think windows has a hosts file as well you can toy with to get a simulated environment in which you can use the real domain names.

proxy

----------

## mycah

Thanks for the response.  I am not a total newbie but I would rate myself a beginner to advanced beginner maybe hehe.

That being said I am not sure I totally get what you are saying.  If I change the settings in /etc/host will that make the html files with links on the server think that the 4 IPs on the machine are attached to those 4 domain names?

Basically, I want to get it setup so I can literally copy and upload my files from the dev server to the production server without having to change any code in my files.

Question:  I guess I could just run a DNS server and set it to resolve the internal virtual IPs on the server to the proper domains? But if I do that how will my workstations on the LAN be able to distinguish btw my dev server and the real domains out on my production server on the Internet?

mycah

----------

## TuxFriend

 *mycah wrote:*   

> If I change the settings in /etc/host will that make the html files with links on the server think that the 4 IPs on the machine are attached to those 4 domain names?
> 
> Basically, I want to get it setup so I can literally copy and upload my files from the dev server to the production server without having to change any code in my files.

 

Not a direct answer to your question but just a hint: It seems that you hardcode the FQDN in you HTML-code. I strongly recommend not to do that. Advise is to redesign your code and remove all hardcoded links.

 *mycah wrote:*   

>  Question:  I guess I could just run a DNS server and set it to resolve the internal virtual IPs on the server to the proper domains? But if I do that how will my workstations on the LAN be able to distinguish btw my dev server and the real domains out on my production server on the Internet?

 

Your workstations won't be able to do that. Having 2 IP-addresses and 1 FQDN isn't going to work without updating your DNS-entries or /etc/hosts when you want to connect to another server. If you do what I mentioned above and register 4 more FQDNs, give them their own IP-addresses you are set to go.

TuxFriend

----------

## klieber

As TuxFriend said, don't hard code the FQDN into your code.  If you can avoid doing this, then you can simply have a dev site named, "dev.mysite.com" instead of "www.mysite.com" and do all your testing on the development server.  The HTML pages will never know the difference.

The only place where this won't work is if you use SSL and have a certificate assigned to a specific domain name.  (and actually, it will still work, but your browsers will complain that the domain names don't match)

--kurt

----------

## mycah

Nod..thanks for the info.

Think I understand it now.

Most of all the links in the sites are relative.

However, I use a few 3rd party scripts for things I havent had time yet to code myself.  And so far it looks like in the setup they require me to hardcode them to the domain name.  Wonder if there is a way around this?

mycah

----------

## klieber

 *mycah wrote:*   

> However, I use a few 3rd party scripts for things I havent had time yet to code myself.  And so far it looks like in the setup they require me to hardcode them to the domain name.  Wonder if there is a way around this?

 

As previously mentioned, place an entry in the /etc/hosts file of your development web server.  This entry should look something like the following:

```
127.0.0.1            www.mysite.com
```

Alternately, you can substitute the real IP address of your dev server for the loopback interface address (127.0.0.1).  Depending on how you have Apache configured, either one should work.

--kurt

----------

## rac

You can also use Apache's name-based virtual hosts to host many different sites in different directories.

----------

## mycah

Thanks for all the info   :Very Happy: 

I have some parts coming in from Newegg on monday or tuesday..and will building the computer and starting the Gentoo install then.

I have a better idea now what I need to look into.  Few things you all said I dont quite understand fully..but I have enough direction now that I think I can read up on it myself.

Thanks a bunch.

Really looking forward to this project lol...new things to learn get me stoked.

mycah

----------

## mycah

Rac,

Yes..that is what I am planning to do.  At the moment I have 4 sites on my production server.  I plan on moving all 4 to my dev server as well.  plus 4 more sites in the hoper to work on.

mycah

----------

## carpman

know this is an old thread but would like to do the same, any updates or howto's on this subject?

cheers

----------

## knopper

As already being said, take a look at the virtual hosting part of the apache manuals.

Besides that, you need to be a bit more specific, what do you want to run on your box?

----------

