0

I have setup PyroCMS as described here: http://docs.pyrocms.com/2.2/manual/setup/environments

I have used the RewriteCondition in Htaccess to automatically determine and set the PYRO_ENV variable:

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]

I'm not using Nginx.

How it should work? Depending on whether you open xyz.com (production) or test.xyz.com (staging) it should accordingly set the global:environment variable and choose the right database connection in database.php.

Issues: - When opening xyz.com (production site), it shows for some variables "production" and for others "development":

_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)
  • PyroCMS doesn't take the right database connection though I setup different databases for production and staging in database.php.

  • Also the global:environment tag doesn't work. When I use the following tag in the CMS, it doesn't show the text on the frontend: {{ if global:environment == 'production' }} // Production-only content {{ endif }}

I also tried another approach in Htaccess with the same results described above:

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

I assume that the htaccess setting above doesn't trigger the right environment to my server. Does anyone has an idea?

Thank you,

Philip

flip
  • 97
  • 3
  • 14
  • Nobody has an idea how I can solve the issue? :-) – flip Sep 04 '13 at 01:07
  • 1
    Have you checked in your index.php file if the PYRO_ENV is actually being set? You will need an allow override in your apache config. Also you need to escape your full-stops like here http://stackoverflow.com/questions/10727720/conditional-setenv-in-htaccess – Nick Pyett Sep 05 '13 at 23:42
  • Thanks for your feedback, Nick! "Have you checked in your index.php file if the PYRO_ENV is actually being set?" -> The environment is defined in index.php. "You will need an allow override in your apache config." -> What do you mean exactly? I don't have root access. What is the name of the variable in Apache which needs to be set? "Also you need to escape your full-stops like here" -> It's mostly escaped in my example above: ^dev\.domain(.+)\.com$ - or do I need to write ^dev\.domain(\.+)\.com$ – flip Sep 14 '13 at 21:18
  • If your PYRO_ENV is actually being set (which you could check with defined(), or just try to echo it), then you don't need to worry about AllowOverride. You need to escape the full-stops that you actually want to be matched as full stops, so "^dev\.xyz\.com$" would be correct. – Nick Pyett Sep 16 '13 at 11:35

0 Answers0