维护同一个PHP网站的多个版本
我正在使用 Php 和 CodeIgniter(在 LAMP 堆栈上)构建一个新网站。一项要求是能够同时运行同一网站的多个版本,例如“实时”版本和“开发”版本; 应该有一种快速、安全的方法来根据需要在版本之间向前和向后切换。
你能推荐一个好的技术吗?
更新
附加要求:
开发人员应该能够轻松创建新版本
最终用户不应该注意到他/她正在使用实时版本,只有开发者可以拥有某种标签
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一般使用配置文件。例如,
将保留特定于该应用程序实例的信息。您的应用程序永远不会从脚本内调用实例特定信息。即 - 您不应该对 DSN、路径、电子邮件地址、图像等进行硬编码。所有这些信息都应包含在配置文件中。
一个例子可能是:
然后,当您需要第二个站点设置时,您只需将修订控制系统(对吗?)签出到另一个目录,然后编辑配置文件以引用测试数据库。
让实时站点和开发站点共享相同的物理数据库(不是数据库引擎,可以在单个 MySQL 数据库服务器上托管 50 个站点,但每个站点都应该在 MySQL 中拥有自己的数据库)通常是不好的做法。
理想情况下,您将有一个安装文件,可以加载一系列测试数据并快速填充新的基础系统。
Generally configuration files are used. For example,
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:
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.
如果您希望在一个 CodeIgniter 安装下运行多个站点,这里有一个解决方案:
http://www.askaboutphp.com /88/codeigniter-setting-up-multiple-sites-on-one-install.html
正如我提到的,如果您有数据库,则需要在设置中记住这一点。
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:
Is really vital to separate them because one vulnerability in dev can be exploited and can bring harm for live version.