zoukankan      html  css  js  c++  java
  • Nginx的虚拟主机配置

    nginx的虚拟主机就是通过nginx.conf中server节点指定的,想要设置多个虚拟主机,配置多个server节点即可
    此处我把别的配置去掉,只留取server配置,方便对比。

    1.基于端口的虚拟主机
    server
    {
    listen 80;
    server_name www.ceshi1.cn;
    index index.html index.htm index.php;
    root /www/wwwroot/ceshi1;

    }
    server
    {
    listen 81;
    server_name www.ceshi2.cn;
    index index.html index.htm index.php;
    root /www/wwwroot/ceshi2;
    }

    2.基于域名的虚拟主机
    server
    {
    listen 80;
    server_name www.ceshi1.cn;
    index index.html index.htm index.php;
    root /www/wwwroot/ceshi1;

    }
    server
    {
    listen 80;
    server_name www.ceshi2.cn;
    index index.html index.htm index.php;
    root /www/wwwroot/ceshi2;
    }
    3.基于IP的虚拟主机
    server
    {
    listen 80;
    server_name 192.168.2.2;
    index index.html index.htm index.php;
    root /www/wwwroot/ceshi1;

    }
    server
    {
    listen 80;
    server_name 192.168.2.3;
    index index.html index.htm index.php;
    root /www/wwwroot/ceshi2;
    }

    验证结果可以使用curl或者wget,也可以使用浏览器。

    ======================================================================

    为了是文件更加的规范化,我们吧server拆开,这样每个server是一个配置文件,方便管理

  • 相关阅读:
    最简单的jQuery插件
    SQL执行时间
    Resharper 8.2 注册码
    Module模式
    RestSharp使用
    使用MVC过滤器保存操作日志
    Ajax Post 类实例
    IBatis分页显示
    IBatis插入类的实例
    Topcoder SRM629 DIV2 解题报告
  • 原文地址:https://www.cnblogs.com/yunweis/p/8041679.html
Copyright © 2011-2022 走看看