阿里云代理商-阿里云服务器-阿里云数据库-重庆典名科技

Nginx常用配置实例

发布时间: 2020-09-18 13:40:15文章作者: 网站编辑阅读量: 280
  Nginx常用配置实例,虚拟主机配置实例下面在Nginx中创建3个虚拟主机,需要说明的是,这里仅仅列出了虚拟主机的配置部分。
  
  http {
  
  server {
  
  listen          80;
  
  server_name     www.domain1.com;    access_log      logs/domain1.
  
  access.log main;    location / {    index index.html;
  
  root  /web/www/domain1.com/htdocs;
  
  }
  
  }  server {
  
  listen            80;
  
  server_name       www.domain2.com;
  
  access_log        logs/domain2.access.log main;
  
  location / {
  
  index index.html;
  
  root  /web/www/domain2.com/htdocs;
  
  }
  
  }
  
  include    /opt/nginx/conf/vhosts/www.domain2.com.conf;
  
  }
  
  这里用到了include指令,其中/opt/nginx/conf/vhosts/www.domain2.com.conf的内容如下:
  
  server {
  
  listen          80;
  
  server_name     www.domain3.com;  access_log      logs/domain3.
  
  access.log main;
  
  location / {
  
  index index.html;
  
  root  /web/www/domain3.com/htdocs;
  
  }
  
  }
联系客服免费领取更多阿里云产品新购、续费升级折扣,叠加官网活动折上折更优惠