同一台服务器上的两个不同的WordPress博客可以使用共同的主题文件夹吗?

时间:2022-12-12 19:22:55

I have two WordPress blogs running on the same server, so they both have access to the same file system. Both blogs use the same template, and this template is duplicated within each theme directory. Every time that I update the theme I need to copy over the new files to both theme directories.

我在同一台服务器上运行了两个WordPress博客,因此他们都可以访问同一个文件系统。两个博客都使用相同的模板,并且此模板在每个主题目录中都是重复的。每次我更新主题时,我都需要将新文件复制到两个主题目录。

Is it possible to have both of these blog share a common theme directory so that I only need to modify one template folder?

是否可以让这两个博客共享一个共同的主题目录,以便我只需要修改一个模板文件夹?

3 个解决方案

#1


Absolutely. Just make sure that they have read and write access to that shared folder.

绝对。只需确保他们对该共享文件夹具有读写权限。

Then set up a symlink from each of the theme folders. You do this with ln -s <origin> <new>

然后从每个主题文件夹中设置符号链接。您可以使用ln -s 执行此操作

If you can't use symbolic links, you can then set up a rewrite-rule, which redirects all requests from /wp-content/themes to like /var/www/shared/themes.

如果您不能使用符号链接,则可以设置重写规则,将/ wp-content / themes中的所有请求重定向到/ var / www / shared / themes。

If you want, I can provide an example.

如果你愿意,我可以提供一个例子。

#2


You can have a symlink link one theme folder to another.

您可以将符号链接链接到另一个主题文件夹。

delete one of the theme folders and use ln like cp

删除其中一个主题文件夹并使用像cp一样的ln

ln -s <source> <dest>

#3


Another approach, if using source control (SVN, Git), would be to checkout the theme into the two locations and update them.

如果使用源代码控制(SVN,Git),另一种方法是将主题签出到两个位置并更新它们。

#1


Absolutely. Just make sure that they have read and write access to that shared folder.

绝对。只需确保他们对该共享文件夹具有读写权限。

Then set up a symlink from each of the theme folders. You do this with ln -s <origin> <new>

然后从每个主题文件夹中设置符号链接。您可以使用ln -s 执行此操作

If you can't use symbolic links, you can then set up a rewrite-rule, which redirects all requests from /wp-content/themes to like /var/www/shared/themes.

如果您不能使用符号链接,则可以设置重写规则,将/ wp-content / themes中的所有请求重定向到/ var / www / shared / themes。

If you want, I can provide an example.

如果你愿意,我可以提供一个例子。

#2


You can have a symlink link one theme folder to another.

您可以将符号链接链接到另一个主题文件夹。

delete one of the theme folders and use ln like cp

删除其中一个主题文件夹并使用像cp一样的ln

ln -s <source> <dest>

#3


Another approach, if using source control (SVN, Git), would be to checkout the theme into the two locations and update them.

如果使用源代码控制(SVN,Git),另一种方法是将主题签出到两个位置并更新它们。