[Web Server] Nginx/Apache 環境變數設定 (Environment Variables)

Intro

Nginx/Apache 環境變數設定速查


Nginx設定

fastcgi_param RUNTIME_ENVIROMENT 'DEV'

For example:

server {
    listen   80; 
    root /var/www/html;
    index index.php;
    server_name localhost;
    location /
    {   
         index index.php;
    }   

    location ~ .*\.(php|php5)?$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param RUNTIME_ENVIROMENT 'DEV'
    }   
}

Apache設定

Environment Variables in Apache

SetEnv RUNTIME_ENVIROMENT DEV

For example:

<VirtualHost *:80>
    DocumentRoot "/var/www/html"
    ServerName localhost
    SetEnv RUNTIME_ENVIROMENT DEV
</VirtualHost>

Nginx 加入 Header

Module ngx_http_headers_module – nginx.org

server {

    add_header Node 'server-a';
    fastcgi_hide_header X-Powered-By;
    #...
}

Leave a Reply

Your email address will not be published. Required fields are marked *