Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
This is a really nice article, thanks!
One important addition that if you do this with Wordpress sites, in addition you also have to search and replace urls with a script. Otherwise you will still be redirected to the live server.
And one question: In my situation I use domain.com as live site and dev.domain.com. as staging site. When I get a let’s encrypt certificate and force redirecting http to https, it replaces the dev.domain.com site to https://domain.com site. How can I: A. exclude this staging site from forcing on https? (in apache virtual hosts) B. If I get a certificate for dev.domain.com, how can I preseve this url in virtual hosts when it’s forcing http://dev.domain.com to https://dev.domain.com, (I don’t want to it being redirect to https://domain.com.
Thanks!
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.
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.
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.