Wordpress 暂存环境 [英] Wordpress staging environment

查看:29
本文介绍了Wordpress 暂存环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一家为制药行业提供网站的公司工作,我们经常需要获得法律批准,然后才能进行任何更改.所以,我想将我们的很多工作迁移到 CMS 环境,特别是 wordpress,但我们需要能够拥有一个临时环境.是否可以不发布页面而将其发布到有人可以使用链接作为站点浏览的登台环境.所以基本上有 2 个网站,一个登台,一个直播?

I work for a company that does sites for the pharma industry and we often need to get legal approval before we push any changes live. So, I'd like to migrate a lot of our work to a CMS environment, specifically wordpress but we need the ability to have a staging environment. Is it possible to instead of publishing a page have it publish to a staging environment that someone can browse as with a link as a site. So basically have 2 sites, one staging one live?

推荐答案

总的来说,上面的答案"是正确的,wordpress 有一些替代方案,它们对暂存环境和构建迁移具有更好的内置支持.然而,建议的替代方案并不完全等同于 wordpress 平台的替代品,所以我认为最好回答手头的问题.

Generally speaking the above "answers" are correct, there are alternatives to wordpress that have better built-in support for staging environments and build migrations. However the suggested alternatives aren't exactly equal substitutes to the wordpress platform, so I think it's best to answer the question at hand instead.

Wordpress 本身不支持从两个不同的主机托管同一站点.核心依赖于存储在数据库中的绝对 url,几乎用于核心逻辑的每个方面.这会导致许多多余的错误,例如与 SSL 访问相关的 500 个左右,因为它们试图动态地将所有 http://方案动态更改为 https://.

Wordpress does not natively support hosting the same site from two different hosts. The core relies on absolute urls stored inside the database and are used in just about every aspect of the core logic. This results in a number of superfluous bugs like the 500 or so related to SSL access because they try to dynamically alter all http:// schemes to https:// on the fly.

因此,当您在 dev.example.com 上托管并迁移到 staging.example.com 并再次迁移到 www.example.com 时,您必须非常仔细地进行搜索和搜索.每次切换主机时替换对数据库导出的操作.当您发现许多流行的 wordpress 插件将 url 序列化为数据库中的值时,这会导致其他问题.所以当你搜索 &用 staging.example.com 替换 dev.example.com 包含原始值字符长度的序列化数据不再使用新的更长格式反序列化.一些核心贡献者认为,解决这个问题的方法是只设置与生产帐户字符数相同的临时站点...

As a result when you host on dev.example.com and migrate to staging.example.com and again to www.example.com you have to do very careful search & replace manipulations on the database export each time you switch hosts. And this causes additional problems when you find out that many popular wordpress plugins serialize the url into values in the database. So when you search & replace dev.example.com with staging.example.com the serialized data which contained the character length of the original value no longer deserializes with the new longer format. Some core contributers believe the solution to this later problem is to only ever setup staging sites with the same number of characters as the production account...

同样,他们还建议交换主机映射,并且只在所有托管环境中使用 production.com 网址.根据您的特定用例要求,如果您需要提供对异地客户、技术文盲用户(当然是技术文盲用户)的访问权限,这可能不是一个有效的解决方案.

In a similar vein they also suggest swapping host mappings and only ever using the production.com url on all hosting environments. Depending on your particular use-case requirements this is probably not a valid solution if you need to provide access to off-site clients, tech-illiterate users (versus tech-literate users of course.)

但 wordpress 本身具有许多出色的功能,并且是一个适应性很强且功能强大的快速开发平台.因此,您可以扩展核心框架来完成您需要的大部分工作.当我遇到这种情况时,我必须开发一个适用于所有情况的解决方案.传统上,此问题是通过相对于根目录的 url 来解决的,它们在跨托管环境中工作,并且不会受到临时迁移中常见的方案更改、端口更改或子域交换做法的影响.

But wordpress itself has a number of great features otherwise and is a very adaptive and powerful rapid development platform. As a result you can extend the core framework to do much of what you need from it. When I was presented with this situation, I had to develop a solution that was viable for all circumstances. Traditionally this problem is solved with root-relative urls, they work in cross-hosting environments, and they don't suffer from scheme changes, port changes or subdomain swapping practices that are common with staging migrations.

使用这个插件:http://wordpress.org/extend/plugins/root-relative-urls/(有偏见?是的,我写了这个插件.)你会得到重要的相对于根的 url 和不工作的相对于根的 url 的动态主机(比如 rss 提要.)从将站点迁移到不同的主机剩下的就是将 wp-config.php 文件移到 www 根目录之外(wordpress 本身支持上一级.)这样您就可以在不同的服务器上维护不同的副本.或者,您可以使用基本的 if 语句通过服务器名称区分主机并根据服务器定义关键字 wordpress 常量.最后你的内容,代码&数据将无缝过渡.

With this plugin: http://wordpress.org/extend/plugins/root-relative-urls/ (biased? yes, I wrote this plugin.) you get root-relative urls where it's important and dynamic hosts where root-relative urls don't work (like rss feeds.) All that remains from migrating the site to different hosts is to move the wp-config.php file outside of the www root (one level up is supported natively by wordpress.) so you can maintain different copies on different servers. Or alternatively you can use basic if-statements to distinguish hosts by server name and define key wordpress constants based on the server. In the end your content, code & data will transition seamlessly.

需要注意的是,引用的插件需要设置对 wp-config.php 文件的写访问权限,从生产或可公开访问的服务器的安全角度来看,这是一个非常糟糕的做法.也许您可以在受限的暂存环境中轻松实现此功能,但随后您需要在生产转换中禁用并删除该插件.

As a note of concern, the referenced plugins require setting write access to the wp-config.php file, a very bad practice from a security perspective for production or publicly accessible servers. Perhaps you can comfortably implement this in a restricted staging environment but then you'd need to disable and remove the plugin in production transitions.

长话短说,是的,您可以在多个主机环境中托管 wordpress.由于核心架构,长期吹捧的解决方案非常特定于案例和选项限制.但该框架足够灵活,可以克服核心赤字.考虑到核心开发人员在克服级联问题上不断花费的大量精力,这个核心设计决策可能会在未来的某个时候发生变化.但也有绝对 url 宗教的虔诚捍卫者将暂时保持这种做法.也许一个不同的平台本身支持服务器迁移(选择其中任何一个,因为大多数人都这样做)现在对您来说是更好的选择.

Long story short, yes you can host wordpress in multiple host environments. The long-touted solutions are very case-specific and option-restricted because of the core architecture. But the framework is flexible enough to overcome the core deficit. This core design decision will probably change at some point in the future given the amount of effort the core developers continually spend on overcoming the cascading issues. But there are also devout defenders of the absolute url religion that will keep the practice in place for the time being. Maybe a different platform that supports server migrations natively (pick just about any of them because most do) would be a better option for you now.

这篇关于Wordpress 暂存环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆