开发者

Better VHOST management in Nginx?

My nginx.conf file is getting larger and large with dozens of vhosts repeating开发者_JS百科 the same lines over and over. I was wondering if there is anyway to declare the following globally without having to repeat them for each project:

# Route all requests for non-existent files to index.php
if (!-e $request_filename) {
 rewrite ^(.*)$ /index.php/$1 last;
}

location ~ \.php($|/) {
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_pass 127.0.0.1:9000;
}


Create a file with the common setup for your vhosts (ie. vhost.conf). Wherever you would like to utilize this common setup, just include that vhost.conf-file.

server {
    include vhost.conf

    location /test {
        # Custom setup for /test
    }
}

Paths are relative to your nginx.conf-file, use absolute paths if specifying vhost.conf outside your nginx.conf-path. http://wiki.nginx.org/NginxHttpMainModule#include

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜