zoukankan      html  css  js  c++  java
  • 基于域名的虚拟主机(最常用)

    最有用的虚拟主机配置方式。

    一个域名只能绑定一个ip地址,一个ip地址可以被多个域名绑定。

    测试:可以修改host文件实现域名访问。

    修改hosts工具推荐:SwitchHosts!

      下载地址:https://github.com/oldj/SwitchHosts/releases

    Centos中的nginx.conf配置如下:

     1     #一个Server就是一个虚拟主机
     2     server {
     3         listen       80;
     4         server_name  192.168.83.133;
     5 
     6         #charset koi8-r;
     7 
     8         #access_log  logs/host.access.log  main;
     9 
    10         location / {
    11             #root   html-133;
    12         root  /home/ftpuser/www;#定义服务器的默认网站根目录位置
    13             index  index.html index.htm;
    14         }
    15 
    16     }
    17 
    18     server {
    19         listen       80;
    20         server_name  192.168.83.132;
    21 
    22         #charset koi8-r;
    23 
    24         #access_log  logs/host.access.log  main;
    25 
    26         location / {
    27             root   html-132;
    28             index  index.html index.htm;
    29         }
    30 
    31     }
    32 
    33     server {
    34         listen       80;
    35         server_name  www.aaa.com;
    36 
    37         #charset koi8-r;
    38 
    39         #access_log  logs/host.access.log  main;
    40 
    41         location / {
    42             root   html-133;
    43             index  index.html index.htm;
    44         }
    45 
    46     }
    47 
    48     server {
    49         listen       80;
    50         server_name  www.bbb.com;
    51 
    52         #charset koi8-r;
    53 
    54         #access_log  logs/host.access.log  main;
    55 
    56         location / {
    57             root   html-132;
    58             index  index.html index.htm;
    59         }
    60 
    61     }

    注意:ip地址和域名必须有

    Windows的host配置:

    浏览器访问:

  • 相关阅读:
    URAL 1948 H
    int、long、long long取值范围
    Bonetrousle HackerRank 数学 + 思维题
    湖南省第十二届大学生计算机程序设计竞赛 problem A 2016
    Abbreviation ---- hackerrank
    POJ 3321 Apple Tree DFS序 + 树状数组
    HDU
    PICO CTF 2013 PHP 2: 85
    XSS进阶三
    XSS进阶二
  • 原文地址:https://www.cnblogs.com/116970u/p/10455073.html
Copyright © 2011-2022 走看看