1

I am building a new website using Php and CodeIgniter (on a LAMP stack). One requirement is to have the facility to run simultaneously more than one version of the same website e.g. a “live” and a “dev” version; There should be a quick and safe way to switch forward and backward between versions, as needed.

Can you suggest a good technique?

UPDATE

Additional requirements:

  • The developer should be able to create a new version easily

  • The end user should not notice he/she is using the live version, only the dev one can have some sort of a tag

Adrian
  • 11
  • 2
  • is this website database dependent? live/dev databases? etc.. need more details I'm afraid, otherwise people will guess and give you answers. – Jakub Dec 17 '10 at 16:42
  • Yes, this website is database dependent; two version should be able to share the same database BUT a dev version might force a schema update so I think switching databases should also be an option – Adrian Dec 17 '10 at 16:47

3 Answers3

2

Generally configuration files are used. For example,

/live.domain.com/conf/config.php

Would retain information specific to that instance of the application. Your application would NEVER call instance specific information from within scripts. Ie - you shouldn't hardcode DSN's, paths, email addresses, images, etc. All that information should be contained within a configuration file.

An example might be:

<?
$dsn_user = 'live';
$dsn_pass = 'live_password_1234234cx';
$dsn_host = 'localhost';
$dsn_type = 'mysql';
$dsn_db   = 'live';
$site_name = 'Bob's Store [live]';
$admin = 'bob@bobsstore.com';
$debug = 0
?>

Then when you need a second site setup, you simply checkout of your revision control system (right?) into another directory, and edit the configuration file to reference the testing database.

It is generally bad practice to have a live and a development site share the same physical database (not database engine, its fine to host 50 sites on a single MySQL database server, but each site should have its own database WITHIN MySQL).

ideally you would have a setup file that could load in a series of test data and populate a new base system quickly.

SirStan
  • 476
  • 4
  • 4
  • I am happy with the idea of having different databases per version; setup files are also good – Adrian Dec 17 '10 at 16:59
0

Here is a solution if you want mutiple sites running under one CodeIgniter install: http://www.askaboutphp.com/88/codeigniter-setting-up-multiple-sites-on-one-install.html

As I mentioned if you have databases you need to keep that in mind in the settings.

Jakub
  • 20,418
  • 8
  • 65
  • 92
0

Just use a subdomain for the dev version. Example:

// prod version
www.example.com

// dev version
dev.example.com

Is really vital to separate them because one vulnerability in dev can be exploited and can bring harm for live version.

s3v3n
  • 8,203
  • 5
  • 42
  • 56
  • Good idea, but I think I need a more flexible way - see update – Adrian Dec 17 '10 at 16:52
  • How do you suggest the "switch" from v1 to v2 should be made? I mean old live version gets archived or deleted, dev becomes live and a new dev version gets uploaded? – Adrian Dec 17 '10 at 17:00
  • Or your developers should learn quickly add subdomains (dev1, dev2 ..), what is a better choice, or you can use subfolders of the dev subdomain ( dev.site.com/dev1, dev.site.com/dev2 ). – s3v3n Dec 17 '10 at 17:01
  • No uploads/downloads. Just move them on server. That is not so difficult. – s3v3n Dec 17 '10 at 17:02
  • So something like this possible? Each version in its own directory e.g. dev.site.com/11 dev.site.com/12 ... Define domain site.com to point to whichever directory contains the live version – Adrian Dec 17 '10 at 17:05
  • Yes, if there are no problems with mod rewrite. subdomains are better – s3v3n Dec 17 '10 at 18:22