nginx虛擬主機

一、編譯安裝完成nginx在這就不說了,前文有具體的安裝過程;


二、排除不需要的內容;

    [root@nginx ~]# egrep -v "#|^$" /etc/nginx/nginx.conf >/tmp/nginx.conf


三、修改內容,拷貝到cp /tmp/nginx.conf /etc/nginx/nginx.conf

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

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

user nginx nginx;

worker_processes  6;

events {

    use epoll;

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {

        listen       80;

        server_name  www.etangbo.com;

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

        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;

        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;

        location / {

            root   /data/blog;

            index  index.html index.htm;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

   }

}

[root@nginx data]# 

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


四、創建網頁文件目錄和授權

   mkdir /data/www -p

   chown -R nginx.nginx /data/www/

   mkdir /app/log -p


[root@nginx ~]# /usr/sbin/nginx -s reload  # 加載配置文件


五、本地hosts做解析:C:\Windows\System32\drivers\etc\hosts

# localhost name resolution is handled within DNS itself.

# 127.0.0.1       localhost

# ::1             localhost

192.168.11.32  www.etangbo.com

192.168.11.32  bbs.etangbo.com 

192.168.11.32  blog.etangbo.com 


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