在 Windows / IIS 上的多个 CakePHP Webroot 之间共享资源?

发布于 2024-09-14 05:55:20 字数 409 浏览 4 评论 0原文

我安装了 CakePHP,运行六个不同的网站,每个网站都有自己的 webroot。所有的基本代码都是相同的(控制器、模型等),只是 css、图像、js 等被分成单独的 webroots(app/webroot、app/webroot_second_site、app/webroot_third_site 等)

。问题是:有没有办法在网络根之间共享公共资源?因此,我们不会有六个不同的 TinyMCE 和 jQuery 副本使我们的项目变得混乱,对我来说更重要的是,这样我们就可以在通用 CSS 文件中进行更改,而不必在六个不同的站点之间复制/粘贴更改。文件夹?

如果这些站点在 Linux 机器上运行,我认为通过从每个 Webroot 到目录树中较高的公共文件夹的符号链接可以相当容易地完成,但我们运行的是 Windows Server 2003 / IIS 6。建议?

I've got a CakePHP install running six different web sites, each with their own webroot. All of the base code is the same (controllers, models, etc.), just the css, images, js and so forth are split into the separate webroots (app/webroot, app/webroot_second_site, app/webroot_third_site, etc.)

My question is: Is there a way to share common resources among the webroots? So we don't have six different copies of TinyMCE and jQuery cluttering up our project, and more importantly to me, so that we can make a change in a common CSS file instead of having to copy/paste a change across six different sites' folders?

If these sites were running on a Linux box, I think it could be fairly easily accomplished with a symlink from each of the webroots to a common folder higher up in the directory tree, but we're running Windows Server 2003 / IIS 6. Any suggestions?

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

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

发布评论

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

评论(3

厌倦 2024-09-21 05:55:20

事实证明,您可以在 NTFS 文件系统中进行目录符号链接。或者至少对于实际目的来说足够接近。 “NTFS Junctions”将满足您的需求。
获取 Sysinternals“Junction”程序作为一个简单的命令行程序来创建/删除这些连接。
然后,您可以将所需的任何公共目录链接到单个主目录。
例如,如果您有

webroot1/
网站根目录2/
webroot3/

每个都有自己的“js/”目录,然后您可以创建

webroot_common/js/

然后符号链接...呃,“创建连接”到该新目录,如下所示:(

junction webroot1/js/common webroot_common/js
junction webroot2/js/common webroot_common/js
junction webroot3/js/common webroot_common/js

是的,“连接”程序接受其输入从 Linux“ln -s”向后)
然后,您可以将所需的任何常见 js 文件(例如 jQuery)放在该公共文件夹中,并将任何特定于站点的 js 文件保留在“webrootX/js”中。

Turns out you can do directory symlinks in NTFS file systems. Or at least close enough for practical purposes. "NTFS Junctions" will work for what you want.
Grab the Sysinternals "Junction" program for a simple command-line program to create/delete these junctions.
Then you can link whatever common directories you need to a single master directory.
For example, if you have

webroot1/
webroot2/
webroot3/

each with their own "js/" directory, then you could create

webroot_common/js/

and then symlink... er, "create junctions" to that new directory like so:

junction webroot1/js/common webroot_common/js
junction webroot2/js/common webroot_common/js
junction webroot3/js/common webroot_common/js

(yes, the "junction" program takes its inputs backwards from Linux "ln -s")
Then you can put whatever common js files you need, like jQuery, in that common folder, and leave any site-specific js files in "webrootX/js".

夕色琉璃 2024-09-21 05:55:20

您可以制作一个静态服务器。添加 DNS 条目,例如 static.yoursite.com。从您的其他站点链接到这些文件 - 也许您只需修改 HTML 帮助程序,以便它自动创建到其他域的链接。

这有助于提高性能,因为您可以运行 nginx 之类的东西来提供这些静态文件。它还将并行化资源检索——大多数浏览器将允许到给定服务器的 2 个连接,因此静态内容与动态内容所需的连接资源竞争。本质上,用户将启动 2 个与动态资源的连接以及 2 个与静态资源的连接。

IME 工作得很好。

You could make a static server. Add a DNS entry to something like static.yoursite.com. Link to those files from your other sites -- probably you could just modify the HTML helper so that it will automatically create links to the other domain.

This can help with performance, because you can run something like nginx to serve these static files. It will also parallelize the resource retrievals -- most browsers will allow 2 connections to a given server, so the static stuff competes with those connection resources that are needed by the dynamic stuff. In essence, the user will start 2 connections to your dynamic stuff as well as 2 connections to the static resources.

Works pretty well IME.

執念 2024-09-21 05:55:20

这会起作用。您将需要重新定义 Windows 服务器的目录,但您会充分理解它。

首先,将您的 APP 和 CAKE 目录放在 public_html 之上。

/var/www/app
/var/www/cake

确保文件夹 cake 中包含所有蛋糕文件夹(蛋糕、供应商等)
将您的网站指向其 public_html 目录。

/var/www/html/site1
/var/www/html/site2

webroot 内容将位于每个 public_html 目录中。现在,修改每个 webroot 中的 index.php 文件以指向同一个应用程序:

if (!defined('ROOT')) {
    define('ROOT', DS.'var'.DS.'www'.DS.'app');
}

if (!defined('APP_DIR')) {
    define('APP_DIR',dirname('app'));
}

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
    define('CAKE_CORE_INCLUDE_PATH', DS.'var'.DS.'www'.DS.'cake');
}

当然,请确保重写已打开。然后,它将全部运行相同的代码,但使用提供index.php 的Webroot。

This will work. You will need to redefine the directories for a windows server, but you will understand it well enough.

First, put your APP and CAKE directories a level above the public_html.

/var/www/app
/var/www/cake

Make sure that the folder cake has all of the cake folders in it (cake, vendors, etc.)
Point your sites to their public_html directories.

/var/www/html/site1
/var/www/html/site2

The webroot content will sit in each of the public_html directories. Now, modify your index.php file in each of the webroots to point to the same app:

if (!defined('ROOT')) {
    define('ROOT', DS.'var'.DS.'www'.DS.'app');
}

if (!defined('APP_DIR')) {
    define('APP_DIR',dirname('app'));
}

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
    define('CAKE_CORE_INCLUDE_PATH', DS.'var'.DS.'www'.DS.'cake');
}

Make sure that rewrite is turned on of course. Then it will all run off the same code but use the webroot where the index.php is being served from.

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