NickTl
By:
NickTl

Best practice for droplets administration on live and staging environments.

November 9, 2015 2.3k views
DNS Getting Started DigitalOcean Git LAMP Stack Deployment Apache WordPress Ubuntu

Hi,

I have now completed my first LAMP stack on Ubuntu and gone live with about 5 sites on one droplet. It was difficult, however fully deserved invested time. Now I am eager to try other options the server allows (e.g. caching, sendmail, etc), but having live sites all changes to the server can be critical.

In order to address risk of changes on Live environment I though that it’s better to establish staging environment and after there is confidence in the result the same changes could be applied to live environment. It seems there are different options can be used. I will list some ideas, but probably you have more professional approach, because I have never had similar experience before.

On per site level it’s possible to create Staging environment using different plugins. For example, in Wordpress there is plugin called WP Staging, which has quite good reviews. Seems to be straightforward, because everything will be hosted on one droplet. No questions here.

On per droplet level it’s possible to create droplet using backup/snapshot, test new solutions and then apply these changes to the droplet with Live sites. It seems to be clear except that I don’t understand how to access my sites on staging environment or easily administrate hosts. 



If I would like to test sites on staging environment and I have several sites, then I can create domain aliases that will point to new IP of Staging droplet, but it seems to be annoying to reconfigure domain settings for 5 sites whenever I make new droplets. (Q1) Is there any smart solution for that? (Q2) Or is any other way to access my sites on staging droplet just using IP?

Also I though it would be wise to use Floating IP. (Q3) Is it so, that I can make changes on Staging droplet and once I am satisfied with the result, then I can forward traffic to from Live droplet to the Staging one, basically turn my Staging droplet to Live droplet? And in this case I still have a questions of accessing my sites while I will be using Staging environment.



I would really appreciate if you would drop a link to materials, that can be researched or share your own experience.

Thanks,
Nick

1 Answer

Hey Nick! Great questions. Let me see if I can address them for you. First I should note that I am not familiar with the WP staging plugin but this would most likely not be the best option when you want to work with things outside WordPress like sendmail.

(Q1) Is there any smart solution for that? (Q2) Or is any other way to access my sites on staging droplet just using IP?

One of the hurdles with any staging environment when dealing with virtualhosts is being able to view the web pages hosted by the staging server. Since you want your staging server to mirror your live server, changing domain names in your virutalhost configuration that will only need to be changed back later is a hassle. There are two other options you can try.

  1. You could add an Alias to your virutalhost configuration on both the live and staging server. Something like mydomain.com.stagingdomain.com. This way the server will respond properly on either it's own domain name or your staging name. By pointing your staging domain to your staging server and your main one to the live server the pages will be served correctly in each environment.

  2. Another option would be to add entries on your local computer's hosts file. This allows you to override DNS results and request the domain from whatever IP address you designate. This is a good way to preview staging content but you will need to delete the hosts file entries to then view the live site again from your computer. On Windows the hosts file is in C:\Windows\system32\drivers\etc while on OS X and Linux it is in /etc/hosts.

(Q3) Is it so, that I can make changes on Staging droplet and once I am satisfied with the result, then I can forward traffic to from Live droplet to the Staging one, basically turn my Staging droplet to Live droplet? And in this case I still have a questions of accessing my sites while I will be using Staging environment.

This would be a good option to be able to quickly switch over to your staging server and have it replace your live server. Either option above would work with this but you would have to re-point your staging domain when doing this if you went with the first option.

Have another answer? Share your knowledge.