nginx配置多站点的实例代码
时间:2015-02-02 15:41 来源:linux.it.net.cn 作者:IT
nginx下配置多站点其实跟apahce差不多。
打开nginx的主配置文件nginx.conf,在最后面添加:
include /etc/nginx/vhosts/*;
vhostsl里面存放着不同站点的配置,把我的例子贴上来供大家参考:
server {
listen 80;
server_name i.it.net.cn;
location / {
root /var/www/tea/blog;
index index.php index.html index.htm;
if (-d $request_filename){
rewrite ^/(.*)([^/])$ $1$2/ permanent;
}
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/tea/blog;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/tea/blog$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
以上代码中包括了nginx的rewirte配置。
(责任编辑:IT)
nginx下配置多站点其实跟apahce差不多。
vhostsl里面存放着不同站点的配置,把我的例子贴上来供大家参考:
server {
location / {
error_page 500 502 503 504 /50x.html;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ /\.ht { 以上代码中包括了nginx的rewirte配置。 (责任编辑:IT) |