Nginx fastcgi 参数没有到达 CodeIgniter
Nginx fastcgi param doesn't get to CodeIgniter
我在 nginx 虚拟主机文件中设置了 fastcgi_param ENVIRONMENT
,但我无法在 CodeIgniter 中访问该值:
var_dump(defined('ENVIRONMENT')); //outputs false
完整的 nginx 虚拟主机文件:
server {
listen 80;
# Hostnames alias
server_name webapp1;
root /home/edson/repositorios/webapp1;
index index.php index.html;
location /bec/admin {
try_files $uri $uri/ /bec/admin/index.php$is_args$args;
}
location /bec {
try_files $uri $uri/ /bec/index.php$is_args$args;
}
#
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include /etc/nginx/php.conf;
fastcgi_param ENVIRONMENT development;
}
# Nginx Cache Control for Static Files (Browser Cache Control Directives)
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml|xls|xlsx|doc|docx|csv|txt)$ {
access_log off;
log_not_found off;
expires max;
}
#
# deny access to .htaccess files, and hidden files, which starts with dot (.), if Apache's document root
# concurs with nginx's one
#
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
}
我是不是做错了什么?
那是一个环境变量,所以可以通过getenv:
访问
Gets the value of an environment variable
例子
getenv('ENVIRONMENT');
我在 nginx 虚拟主机文件中设置了 fastcgi_param ENVIRONMENT
,但我无法在 CodeIgniter 中访问该值:
var_dump(defined('ENVIRONMENT')); //outputs false
完整的 nginx 虚拟主机文件:
server {
listen 80;
# Hostnames alias
server_name webapp1;
root /home/edson/repositorios/webapp1;
index index.php index.html;
location /bec/admin {
try_files $uri $uri/ /bec/admin/index.php$is_args$args;
}
location /bec {
try_files $uri $uri/ /bec/index.php$is_args$args;
}
#
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include /etc/nginx/php.conf;
fastcgi_param ENVIRONMENT development;
}
# Nginx Cache Control for Static Files (Browser Cache Control Directives)
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml|xls|xlsx|doc|docx|csv|txt)$ {
access_log off;
log_not_found off;
expires max;
}
#
# deny access to .htaccess files, and hidden files, which starts with dot (.), if Apache's document root
# concurs with nginx's one
#
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
}
我是不是做错了什么?
那是一个环境变量,所以可以通过getenv:
访问Gets the value of an environment variable
例子
getenv('ENVIRONMENT');