Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

localhost + staging + production environments?

I have a website say www.livesite.com which is currently running. I have been developing a new version of the website on my local machine with http://localhost and then committing my changes with svn to www.testsite.com where I would test the site on the livesite.com server but under another domain (its the same environment as the live site but under a different domain).

Now I am ready to release the new version to livesite.com. Doing it the first time is easy, I could just copy & paste everything from testsite.com to livesite.com (not sure its the best way to do it).

I want to keep testsite.com as a testing site where I would push updates, test them and once satisfied move to livesite.com but I am not sure how to do that after the new site is launched.. I don't think copy pasting the whole directory is the right way of doing it and it will break the operations of current users on the livesite.com.

I also want to keep my svn history on testsite.com. What is the correct way of doing this with SVN ? Thank you so much!

like image 718
Kentor Avatar asked Dec 29 '10 03:12

Kentor


People also ask

What is production and staging environment?

A staging environment (stage) is a nearly exact replica of a production environment for software testing. Staging environments are made to test codes, builds, and updates to ensure quality under a production-like environment before application deployment.

What is the difference between staging and production?

The staging area contains the "next" version of the application and is used for final stress testing and client/manager approvals before going live. production: This is the currently released version of the application, accessible to the client/end users.

What is the difference between staging and UAT?

The staging environment would be under control of the operations team, to ensure that roll-outs occur properly. The user-acceptance-test (UAT) environment would be used by the customer team. There might also be a production-snapshot environment for reproducing customer issues.


1 Answers

Other answers mentioning Hudson or Weploy are good. They cover more issues than what follows. That said, the following may be sufficient.

If you feel that's overkill, here's the poor-man's way of doing it with SVN and a little creative sysadminning.

Make your proudction document root a symlink, not an actual directory. Meaning you have something like this:

/var/www/myproject-1-0-0
/var/www/myproject-1-1-0
/var/www/myproject-1-1-1
/var/www/html -> myproject-1-1-1

This means you can check out code onto production (say, myproject-1-1-2) without overwriting stuff being served. Then you can switch codebases near-instantly by doing something like:

$ rm html && ln -s myproject-1-1-2 html

I'd further recommend not doing an svn checkout/svn export of your trunk on the production box. Instead, create a branch ahead of time (name it something like myproject-X-Y-Z). That way if you need to do some very stressful tweaking of production code, you can commit it back to the branch, and merge it back to trunk once the fire is extinguished)

I do this a lot, and it works quite well. However, it has some major drawbacks:

Mainly, you have to handle database migrations, or other upgrade scripts, all by yourself. If you have scripts (plain-old-SQL, or something more involved), you need to think about how best to execute them. Downtime of hopefully-just-a-minute might not be a bad idea. You could keep a "maintenance site" around (/var/www/mainenance), and point the symlink there for a few moments if you needed to.

This method is not nearly as cool as Weploy, for example, but for relatively small projects (running on a single server, with not-huge databases), it's often good enough, and dead simple.

like image 63
timdev Avatar answered Sep 30 '22 01:09

timdev