TurnKey Linux Virtual Appliance Library

Working with sub-domains, CNAMES and A records

I'd like some help please in learning how to create DNS records using the WordPress appliance on Amazon. Here's what I'm trying to do:

We have a live server on the internet that has a small number of sites running WordPress multisite.

We need to rebuild this WordPress multisite installation, and I'm hoping to use Turnkey WordPress on Amazon as a place to build a clone of the real system which can then be migrated out to the live environment.

Let's say my parent site is parent.com and the sub-sites are subsiteA.com and subsiteB.com.

I have to use the actual domain names in both environments. What I had planned to do was to edit the hosts file on a PC so that visiting parent.com, subsiteA.com and subsiteB.com go the the IP address (elastic) of my Turnkey Cloud Appliance.

For that to work I need to be able to create A records and CNAME records and sub-domains on the server appliance itself so that traffic is routed appropriately. I don't want these records to be created in any sort of public DNS system because there's still a real live site out there that needs to carry on working.

I'm used to using Advanced DNS Editor in Cpanel on other servers. Where do I find/install/activate/access something like that on Turnkey WordPress EC2?

Thanks in advance

Ian

Jeremy's picture

Why do you need to create (fake) DNS records?

Adding the IP to your hosts file should do the job fine. I'm not sure why you'd also need to create DNS records? When you try to connect to a url, the first thing that is checked is the hosts file. If a entry exists there then DNS is never querried. It's only when no hosts record exists that your PC will ask DNS for an IP...

Regardless though, if you want to install a local DNS server on your appliance then you could do that too. Then just make your server your primary DNS (on your local computer.

To install DNS:

apt-get update
apt-get install bind9 webmin-bind9

Then you can configure it through Webmin.

Where this whole idea will possibly fall down though is that unless you have an elastic IP associated with your appliance, the pubic IP may change and you will lose domain based contact with your server (whether you go the hosts or DNS route). The only other way around that is to use alternative domain names (so they don't interfere with your real site). You could use HubDNS for that and one of the free tklapp.com domain names...

I think I've got it

Thanks Jeremy for taking the trouble to suggest a way forward. I think I have an approach that will work now, but I haven't tried it yet. I'll post back when I do.

I'm creating a copy of a live WordPress multisite installation. WordPress multisite installations use several URLS for different sites, so we need to be able to create and edit a series of CNAME and A records within DNS.

Here's what I'm going to try:

  1. I have a Turnkey WordPress Cloud Server with Elastic IP
  2. I have PC (in fact a local virtual machine) that will connect to the Turnkey WordPress Cloud Server
  3. Only the PC will be allowed to access the Turnkey WordPress Cloud Server (firewall rule)
  4. The hosts file on the PC will point to the Turnkey WordPress Cloud Server's elastic IP for all the domains in our multisite network
  5. Inspired in part by Jeremy's response, I'm going to try using the hosts file as a sort of substitute for CNAMEs and A records, pointing each domain and subdomain that is required at my Elastic IP address by editing the hosts file.
  6. The real-world name servers for the sites won't change, so the rest of the world will see the live sites

It's point 5 in that list that I'm unsure about. I'll let you know how I get on.

One more detail

Am I right in thinking that I also need to create virtual hosts for the domains parent.com, subsiteA.com and subsiteB.com?

Jeremy's picture

You got it!

Personally I like to do them as separate 'sites' (ie separate entries in /etc/apache2/sites-available) and then enable them with a2ensite <site-name>

Ric Moore's picture

Can you recommend a good simpe apache2 how-to??

I'd give my left leg to see you do a step-by-step video setting up apache2 virtual servers. I might bid upwards by offering my right foot. Ric


Ric Moore's picture

That is what I missed! ...I think

I tried to do the apache2/sites/sites-available edis, whch didn't work. I think I missed that last step. Can webmin be added to the base proxmox install, or just containers? Ric


Virtual Hosts weren't required

Just a quick update, I found that I didn't need to set up any Virtual Hosts on the server to create the environment that I needed. It was enough just to have the hosts file.

I believe that this piece of luck is specific to the task that I was attempting, which was to work with WordPress multisite. WordPress Multisite's own sunrise and domain mapping must be doing some of the work here.

To recap, I'm using WordPress Multisite with a sub-domain configuration and the WordPress MU Domain Mapping plug-in. parent.com is the parent site, subsiteA.com and subsiteB.com are sites on the multisite network.

Here's what my hosts file looks like, except of course xxx.xxx.xxx.xxx is really my Elastic IP address and not a load of x's.

xxx.xxx.xxx.xxx  parent.com

xxx.xxx.xxx.xxx  www.parent.com

 

xxx.xxx.xxx.xxx  subsiteA.com

xxx.xxx.xxx.xxx  www.subsiteA.com

xxx.xxx.xxx.xxx  subsiteA.parent.com

xxx.xxx.xxx.xxx  www.subsiteA.parent.com

 

xxx.xxx.xxx.xxx  subsiteB.com

xxx.xxx.xxx.xxx  www.subsiteB.com

xxx.xxx.xxx.xxx  subsiteB.parent.com

xxx.xxx.xxx.xxx  www.subsiteB.parent.com

 

Hope this helps anyone else who's setting up WordPress multisite development environments on Turnkey Linux and Amazon EC2

 

(btw, the URLs in this post have been automatically turneded into links by the commenting system here. They should just be plain text).

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)