nginx虛擬主機包含配置方式(也可以一個虛擬主機配置一個單獨的文件)

[root@nginx log]# cat /etc/nginx/nginx.conf

user nginx nginx;

worker_processes  6;

error_log  /app/log/nginx_error.log  crit;

#pid        logs/nginx.pid;

events {

    use epoll;

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    #日誌格式

    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  /app/log/http.access.log main;

    keepalive_timeout  65;

    include extra/*;    

}

###################################################################################

[root@nginx bbs]# mkdir /extra/    #創建目錄

server {

        listen       80;

        server_name  www.etangbo.com;

        #日誌存放路徑

        access_log  /app/log/www/host.access.log main;

        location / {

            root   /data/www;

            index  index.html index.htm;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

    }

###

     server {

        listen       80;

        server_name  bbs.etangbo.com;

        #日誌存放路徑

        access_log  /app/log/bbs/host.access.log  main;

        location / {

            root   /data/bbs;

            index  index.html index.htm;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        } 

   }

###

    server {

        listen       80;

        server_name  blog.etangbo.com;

        #日誌存放路徑

        access_log  /app/log/blog/host.access.log  main;

        location / {

            root   /data/blog;

            index  index.html index.htm;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

   }


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章