奇怪的问题。在我的Nginx vhost配置中,我设置了诸如ENV之类的变量来告诉PHP它是否应该根据环境采取不同的行为。
例如:
location / {
...
fastcgi_param ENV production;
...
}
然后PHP读取它:
<?php
if($SERVER['ENV'] == 'production' {
//Do This
} else {
//Do That
}
这正常。但是当通过cname访问站点时,似乎不再读取ENV变量。可能导致这种情况的原因是什么?
完整服务器BLock
server {
listen 80;
server_name example.com www.example.com;
location / {
root /data/sites/www.example.com/public_html/;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?rt=$uri&$args;
}
location ~ \.php$ {
root /data/sites/www.example.com/public_html/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param ENV production;
fastcgi_param HTTPS off;
}
}