[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;
}
}
}
本文出自 “山猫” 博客,谢绝转载!
nginx虚拟主机包含配置方式(也可以一个虚拟主机配置一个单独的文件)
原文地址:http://cqtangbo.blog.51cto.com/2978612/1754184