在相同的模板驱动网站之间共享通用逻辑的最佳方式是什么?

发布于 2024-08-23 03:52:30 字数 436 浏览 4 评论 0原文

我用 PHP 构建了一个使用模板的白标签网站。每个白色标签都有自己的一组模板,可能还有一些额外的文件夹。所有白标站点都位于同一台 LAMP 服务器上。

我想做的是在服务器上保留一份主代码的集中副本,然后让每个站点都指向这些文件。然后,每个白标签站点目录将有一个用于其模板以及任何其他额外文件和目录的物理目录。

这个想法是从演示中完全删除逻辑并在所有白标签站点之间共享逻辑。这样我就可以更改共享逻辑,并且所有站点都会更新。

我还需要 SVN 存储库中的类似结构。目前,每个白标网站都有自己的存储库。

实现这一目标的最佳方法是什么?我可以使用 mod_rewrite 之类的东西将除模板之外的所有请求转发到共享文件夹吗?

  1. 我需要确定的是 设置新的白色很容易 标签网站
  2. 结帐白标签的用户 从 SVN 复制品开始处理它 模板无权访问 共享代码

I've built a white label website in PHP that uses templates. Each white label will have it's own set of templates and possibly a few extra folders. All the white label sites are on the same LAMP server.

What I would like to do is keep one centralised copy of the main code on the server and then have every site point to these files. Then each white label site directory will have a physical directory for it's templates and any other extra files and directories.

The idea is to completely remove the logic from the presentation and share the logic across all the white label sites. This way I can make changes to the shared logic and all the sites will update.

Also I need a similar structure in the SVN repositories. Currently each white label site has it's own repository.

What's the best way to achive this? Can I use something like mod_rewrite to forward all requests apart from templates to shared folder?

  1. What I need to make sure is that
    it's easy to set up a new white
    label site
  2. Users that checkout a white label
    from the SVN repro to work on it's
    templates don't have access to the
    shared code

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木有鱼丸 2024-08-30 03:52:30

在 Apache 中,您可以设置一个别名目录,可以从多个不同的网站访问该目录,

这里我将其称为 common_files

<VirtualHost 100.100.100.100>
  ServerName example.com
  DocumentRoot "/usr/example/html_docs"
  <Directory "/usr/example/html_docs">
    AllowOverride All
    Allow from All
    DirectoryIndex index.htm, index.php
  </Directory>
  Alias /sf "/usr/common_files"
  <Directory "/usr/common_files">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

In Apache you can setup an alias directory which can be accessed from several different web sites

Here I have called it common_files

<VirtualHost 100.100.100.100>
  ServerName example.com
  DocumentRoot "/usr/example/html_docs"
  <Directory "/usr/example/html_docs">
    AllowOverride All
    Allow from All
    DirectoryIndex index.htm, index.php
  </Directory>
  Alias /sf "/usr/common_files"
  <Directory "/usr/common_files">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>
傲世九天 2024-08-30 03:52:30

最后我决定使用符号链接来链接到共享文件。然后,我创建了一个交互式 bash 脚本来自动设置新白色标签的符号链接。

In the end I decided to use Symbolic Links to link to the shared files. I then created a interactive bash script to automatically set-up the symlinks for new white labels.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文