码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx 配置基于域名的虚拟

时间:2014-12-25 15:59:53      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

编辑配置文件

vi /etc/nginx/nginx.conf

user    www www;
worker_processes  2;

error_log  logs/error.log  notice;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
                      ‘$status $body_bytes_sent "$http_referer" ‘
                      ‘"$http_user_agent" "$http_x_forwarded_for"‘;

    access_log  /data/logs/www-logs/http/access.log  main;
    sendfile        on;
    keepalive_timeout  65;

    client_header_buffer_size 1k;
    large_client_header_buffers 4 4k;

    gzip  on;

#虚拟主机1 

  server {
        listen       80;
        server_name  www.site1.com;
        access_log  /data/logs/www-logs/www.site1.com/host.access.log  main;

        location / {
            root   /data/web/www.site1.com/htdocs;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

 

#虚拟主机2  

 server {
        listen       80;
        server_name  www.site2.com;
        access_log  /data/logs/www-logs/www.site2.com/host.access.log  main;

        location / {
            root   /data/web/www.site2.com/htdocs;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

 

#虚拟主机3   

server {
        listen       80;
        server_name  www.site3.com;
        access_log  /data/logs/www-logs/www.site3.com/host.access.log  main;

        location / {
            root   /data/web/www.site3.com/htdocs;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

}

 

Nginx 配置基于域名的虚拟

标签:

原文地址:http://www.cnblogs.com/kongxs/p/4184672.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!