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
精彩评论