2

Let's say my main site is www.mySite.com . The path is:

/home/itsme/public_html/

I want to set up a staging server at staging.mySite.com which redirects to:

/home/itsme/public_html/staging

Can I do this with a CNAME to make it happen?:

staging    CNAME          www.mySite.com/staging.

Or will that fail because the destination is not a root domain?

4

This will not work.

A CNAME record in DNS makes an alias of one domain name for another, and has no connection to any other part of a url.

What you can do is use a CNAME or just multiple A records in DNS to make sure both addresses point at the same machine and then on that machine configure your webserver to enable multiple virtual hosts responding to the different names.

How you do this will vary depending on the webserver software you're running. How to do it with Apache is described in the Apache docs on Virtual Hosts.

1
  • any idea how to do what I'm describing? – Shackrock Jul 15 '11 at 1:34
0

Okay. Well you have a lot of possible solutions to such a deployment process.

What Don wrote is a nice one. If you're using Apache Virtual Hosts make it very easy to host multiple independant sites on on IP, but its only handy if you can control your DNS or wanna apply your local static host configuration (/etc/hosts or %SystemRoot%\system32\drivers\etc\hosts).

You have to understand how HTTP works. I don't know how deep you're into that. Just in a short: The idea is to create a new domain, prefixed for example, just like "test.YOURDOMAIN.COM" and let it have its completely own directory, not a subdir. If you make an entry to your HOSTS file on your client, you can use your browser to access that web site actually on your server, that does not really host that domain but with that hosts configuration your browser will ask for the testing domain and retrieve those files if you configured your server correctly. In your case (actually you seem to have DNS access) you can leave the hosts-file part out, because maybe you really can configure your own subdomains.

That approach is nice, because you can switch easily - immediately without service interruption or side effects (enable/disable sites, reconfigure apache). You won't have to mess around with directories and create perhaps insane filesystem states if access is not disabled, services get unavailable... a mess for a heavy load site - or if you wanna maintain service quality - the better way.

So if you wanna do it this way, and you have an apache, you would...

  1. Create a virtual host (http://httpd.apache.org/docs/2.2/en/vhosts/) with a fictional domain prefix
  2. Apply your production virtual host, so your customers still reach your site, test it twice and tunneld :)
  3. Add the Domain name to your hosts file from where you run the tests
  4. Check if it really works and your site is still available

For a Debian GNU/Linux Server Environment and can give you more detailed hints. RHEL derivates I don't have enough experiences.

1
  • I update my code, then upload to the staging server (on my production server, but separated) - test it thoroughly - then when I'm happy with it I migrate to the live production server. – Shackrock Jul 15 '11 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.