Maintain multiple versions of the same Php website
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 v开发者_StackOverflow社区ersion 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
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.
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.
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.
精彩评论