首先配置nginx.conf

[root@localhost conf]# cat nginx.conf
worker_processes 1;
user nginx nginx;
error_log /app/log/nginx.error.log;

events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include extra/nginx.vhosts.conf; #包含文件
log_format main '$remote_addr - $remote_user [$time_local] "$request" ';
error_page 500 502 503 504 /50x.html;
}

 vim /workspace/nginx/conf/extra/nginx.host.conf

#只写server
server {
listen 80;
server_name localhost;
location / {
index index.jsp index.htm index.html;
root /data0/www/www;
access_log /app/log/www.access.log;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
###
server {
listen 100;
server_name localhost;
location / {
index index.jsp index.htm index.html;
root /data0/www/bbs;
access_log /app/log/www.access.log;
}
}

###
server {
listen 200;
server_name localhost;
location / {
index index.jsp index.htm index.html;
root /data0/www/blog;
access_log /app/log/www.access.log;
}
}