0

我已经按照此处所述设置了 PyroCMS:http: //docs.pyrocms.com/2.2/manual/setup/environments

我在 Htaccess 中使用了 RewriteCondition 来自动确定和设置 PYRO_ENV 变量:

RewriteCond %{HTTP_HOST} ^dev.xyz.com$
RewriteRule (.*) $1 [E=PYRO_ENV:development]

RewriteCond %{HTTP_HOST} ^test.xyz.com$
RewriteRule (.*) $1 [E=PYRO_ENV:staging]

RewriteCond %{HTTP_HOST} ^xyz.com$
RewriteRule (.*) $1 [E=PYRO_ENV:production]

我没有使用 Nginx。

它应该如何工作? 根据您是打开 xyz.com(生产)还是 test.xyz.com(暂存),它应该相应地设置 global:environment 变量并在 database.php 中选择正确的数据库连接。

问题: - 打开 xyz.com(生产站点)时,它显示一些变量“生产”和其他“开发”:

_REQUEST["www_pyrocms_development"] 2MH5lsDV3Cb3YK+6IcCrFaIH6Aeu98rIwKcgAaTcFnQsB5Vwn9ySGb3R3QfNTqvMoJsrfjDXv/PLdfYrVjr/IOREQhQIvsa1E+mozs5gYH6lC1+/mORDm2pN//InQBHTJGQsr3Y5jfzNYjakxXOArMRn2hmt14a18TON0VKMjpKjaBrl2aFx+CjypvIdF0oI4aXrK0HIWjhCl+VTdea4gFQzD6g7RblmKwHoJKCdYRCytWZ8z6y1HT3TQDMUOij3xqCXswrY0GD/bDfVvz16Ru07J8Y1z9v4Ye2hF8z7TiwomPIQgyiP+RSaOAebVRpF103KQvgjJjL5oSaywHiqX7noLEqQRsMjjaZFKMOgIpbtJoilytKby1TrdezhK4cFu/Kq1vTExhTXHQkIODp/ofbtNnSZB4pNh5RXdv4hIBM=

_COOKIE["www_pyrocms_development"]  2MH5lsDV3Cb3YK+6IcCrFaIH6Aeu98rIwKcgAaTcFnQsB5Vwn9ySGb3R3QfNTqvMoJsrfjDXv/PLdfYrVjr/IOREQhQIvsa1E+mozs5gYH6lC1+/mORDm2pN//InQBHTJGQsr3Y5jfzNYjakxXOArMRn2hmt14a18TON0VKMjpKjaBrl2aFx+CjypvIdF0oI4aXrK0HIWjhCl+VTdea4gFQzD6g7RblmKwHoJKCdYRCytWZ8z6y1HT3TQDMUOij3xqCXswrY0GD/bDfVvz16Ru07J8Y1z9v4Ye2hF8z7TiwomPIQgyiP+RSaOAebVRpF103KQvgjJjL5oSaywHiqX7noLEqQRsMjjaZFKMOgIpbtJoilytKby1TrdezhK4cFu/Kq1vTExhTXHQkIODp/ofbtNnSZB4pNh5RXdv4hIBM=

_SERVER["REDIRECT_PYRO_ENV"]    production

_SERVER["HTTP_COOKIE"]  www_pyrocms_development=2MH5lsDV3Cb3YK%2B6IcCrFaIH6Aeu98rIwKcgAaTcFnQsB5Vwn9ySGb3R3QfNTqvMoJsrfjDXv%2FPLdfYrVjr%2FIOREQhQIvsa1E%2Bmozs5gYH6lC1%2B%2FmORDm2pN%2F%2FInQBHTJGQsr3Y5jfzNYjakxXOArMRn2hmt14a18TON0VKMjpKjaBrl2aFx%2BCjypvIdF0oI4aXrK0HIWjhCl%2BVTdea4gFQzD6g7RblmKwHoJKCdYRCytWZ8z6y1HT3TQDMUOij3xqCXswrY0GD%2FbDfVvz16Ru07J8Y1z9v4Ye2hF8z7TiwomPIQgyiP%2BRSaOAebVRpF103KQvgjJjL5oSaywHiqX7noLEqQRsMjjaZFKMOgIpbtJoilytKby1TrdezhK4cFu%2FKq1vTExhTXHQkIODp%2FofbtNnSZB4pNh5RXdv4hIBM%3D; www_csrf_cookie_name=ced9bc01dc6439bdb4716964fe037173; www_identity=info%40xyz.com; www_remember_code=76aec0ab8b6b09091c1659bcf72d962b5337e226; web6_SID=89280348f350ecae51a672da350d8b7c; __utma=163786799.1178091424.1375554048.1375566051.1375568373.5; __utmb=163786799.3.10.1375568373; __utmc=163786799; __utmz=163786799.1375554048.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
  • 尽管我在 database.php 中为生产和登台设置了不同的数据库,但 PyroCMS 没有采用正确的数据库连接。

  • 全局:环境标签也不起作用。当我在 CMS 中使用以下标签时,它不会在前端显示文本: {{ if global:environment == 'production' }} // 仅生产内容 {{ endif }}

我还在 Htaccess 中尝试了另一种方法,结果与上述相同:

SetEnvIf Host ^dev\.domain(.+)\.com$ PYRO_ENV=development
SetEnvIf Host ^test\.domain(.+)\.com$ PYRO_ENV=staging
SetEnvIf Host ^(www\.)?domain(.+)\.com$ PYRO_ENV=production

我假设上面的 htaccess 设置不会触发我的服务器的正确环境。有人有想法吗?

谢谢,

菲利普

4

0 回答 0