您的位置:首页 > 运维架构 > Nginx

nginx基于端口的虚拟主机:

2016-03-23 10:29 513 查看
[root@nginx extra]# cat /etc/nginx/nginx.conf
user nginx nginx;
worker_processes 6;
error_log /app/log/nginx_error.log crit;
pid /app/log/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/*.conf;
}
[root@nginx extra]#
[root@nginx extra]# cat www.conf
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;
}
}

[root@nginx extra]# cat bbs.conf
###
server {
listen 8081;
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;
}
}
[root@nginx extra]# cat blog.conf
###
server {
listen 8080;
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;
}
}
[root@nginx extra]#

################################################
还可以做基于IP的虚拟主机,这儿就不演示了,很简单
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息