首页 > 代码库 > Nginx 虚拟主机配置
Nginx 虚拟主机配置
在 nginx.conf 中,一个 Server块 就是一个虚拟主机,一个虚拟主机就是一个独立的 Web站点
(1) 基于域名的虚拟主机:通过不同的域名区分不同的虚拟主机,最常用
(2) 基于端口的虚拟主机:通过不同的端口区分不同的虚拟主机
(3) 基于 IP 的虚拟主机:通过不同的 IP 区分不同的虚拟主机
worker_processes 1;user nobody nobody;pid /usr/local/nginx/nginx.pid; events { worker_connections 1024;} http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name www.xxxxx.com; location / { root html/www; index index.html index.htm; } }}
worker_processes 1;user nobody nobody;pid /usr/local/nginx/nginx.pid; events { worker_connections 1024;} http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name www.xxxxx.com; location / { root html/www; index index.html index.htm; } } server { listen 80; server_name bbs.xxxxx.com; location / { root html/bbs; index index.html index.htm; } } server { listen 80; server_name blog.xxxxx.com; location / { root html/blog; index index.html index.htm; } }}
worker_processes 1;user nobody nobody;pid /usr/local/nginx/nginx.pid; events { worker_connections 1024;} http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name www.xxxxx.com; location / { root html/www; index index.html index.htm; } } server { listen 81; server_name bbs.xxxxx.com; location / { root html/bbs; index index.html index.htm; } } server { listen 82; server_name blog.xxxxx.com; location / { root html/blog; index index.html index.htm; } }}
## 前提:要有多个网卡worker_processes 1;user nobody nobody;pid /usr/local/nginx/nginx.pid; events { worker_connections 1024;} http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 192.168.1.1:80; server_name www.xxxxx.com; location / { root html/www; index index.html index.htm; } } server { listen 192.168.1.2:80; server_name bbs.xxxxx.com; location / { root html/bbs; index index.html index.htm; } } server { listen 192.168.1.3:80; server_name blog.xxxxx.com; location / { root html/blog; index index.html index.htm; } }}
Nginx 虚拟主机配置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。