Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to apply code updates to a running website?

Tags:

php

How can I apply code changes to my running website, if I have bug fixes or updates? The simplest way I can think of is to set up the same site in a different directory for testing the changes, and then put my website offline for a period of time to update the files.

Is there a better way?

like image 595
Arshdeep Avatar asked Jun 27 '10 22:06

Arshdeep


1 Answers

Creating a copy of the live site is certainly a good step, applying changes to the copy before applying the same to the live site.

A common production environment would include a further set of steps.

  1. Run a local development copy
    Have a copy of your website running on your development machine. This requires that you development machine is running a web server, database server and, if necessary, a mail server.

    For PHP/Apache/MySQL environments, take a look at http://www.apachefriends.org/en/xampp.html.

    You can safely develop, break, test and change a your local development environment

  2. Source control
    Use Subversion, Mercurial or Git to keep your code under source control. Ensure your local development environment is kept under source control. Ensure your live environments are under source control. Develop locally, test changes and commit the changes back.

  3. Staging and live environments
    Maintain more than one 'live' copy - the actual live public site and as close a replica as possible. Ensure both are under version control.

    Once locally-tested changes have been tested, update your staging environment (usin your source control system) and test again. Once your staging site is stable, you can use your source control system to update your live site.

    There will not generally be much of a need to take the real live site offline to apply updates, but be sure that you can safely do so if needed.
like image 125
Jon Cram Avatar answered Oct 12 '22 23:10

Jon Cram