三个语法格式说明:
①. 大括号要成对出现
②. 每一行指令后面要用分号结尾
③. 每一个指令要放置在指定的区块中
(一)实现编写一个网站页面
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.etiantian.org;
location / {
root html/www; (注意:mkdir /application/nginx/html/www vim /application/nginx/html/www/index.html)
index index.html index.htm;
}
}
}

(二)实现编写多个网站页面==编写多个虚拟主机(等于一个网站)
第一个里程编写配置文件:
server {
listen       80;
server_name  www.etiantian.org;
location / {
    root   html/www;
    index  index.html index.htm;
}
}
server {
    listen       80;
    server_name  bbs.etiantian.org;
    location / {
        root   html/bbs;
        index  index.html index.htm;
    }
}
server {
    listen       80;
    server_name  blog.etiantian.org;
    location / {
        root   html/blog;
        index  index.html index.htm;
    }
}

第二个里程创建站点目录:
mkdir -p /application/nginx/html/{www,bbs,blog}

第三个里程创建站点目录下首页文件:
for name in www bbs blog;do echo "10.0.0.7 $name.etiantian.org" >/application/nginx/html/$name/index.html;done
for name in www bbs blog;do cat /application/nginx/html/$name/index.html;done
10.0.0.7 www.etiantian.org
10.0.0.7 bbs.etiantian.org
10.0.0.7 blog.etiantian.org

第四个里程:进行访问测试
浏览器访问测试:
注意:需要编写windows主机hosts文件,进行解析
命令行访问测试:
利用curl命令在linux系统中访问测试
注意:需要编写linux主机hosts文件,进行解析

扩展(二) 实现编写多个网站页面==编写多个虚拟主机的另一种方法(解决nginx.conf配置文件配置多个虚拟主机导致的文件内容过大)
根据上面多个网站页面做如下修改:
第一个里程创建各页面配置文件文档:
cd /application/nginx/conf/
mkdir extra/
touch extra/{www.conf,bbs.conf,blog.conf}
第二个里程写入各页面server配置部分:
sed '18,25p' -n /application/nginx/conf/nginx.conf > bbs.conf 
sed '10,17p' -n /application/nginx/conf/nginx.conf > www.conf 
sed '26,33p' -n /application/nginx/conf/nginx.conf > blog.conf 

第三个里程更改主配置文件:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include extra/www.conf;
include extra/blog.conf;
include extra/bbs.conf;
}