0

假设我在服务器 a、b 和 c 中托管了 3 个网站,它们都使用一些相同的文件(library.php、users.php、config...)。现在所有网站都有这些文件,如果我想更新其中 1 个文件,我必须为所有网站更新。非常低效。

问题是我是否可以拥有一个托管这些公共文件的中央服务器,并且当加载其中一个网站时,我让 PHP 从中央服务器调用 library.php、users.php...?

4

2 回答 2

2

You COULD use a central server, or set one of the 3 servers as the shared respository for all files, but that is going to cause unnecessary network overhead and also reintroduce a single point of failure.

A better method would be to implement a set of scripts that would keep the servers in sync.

Rsync can be used for this, but there are any number of options including using git. (You DO use source code management right?)

Capistrano is also a good option.

Also see answers here: Deploying to multiple servers

于 2014-01-08T15:14:11.880 回答
0

将它们放在服务器上的共享目录中,并将它们添加到 PHP 包含路径中。

于 2014-01-08T15:08:30.330 回答