首先修改hosts文件,让浏览器在看到a.com或是www.a.com的网址时知道上哪里去找:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
127.0.0.1 a.com
127.0.0.1 www.a.com

打开nginx.conf,写入下面两段:

    server {
        listen       7777;
        server_name  a.com;

        location / {
            root   html/7777;
            index  index.html index.htm;
        }
    }

    server {
        listen       9999;
        server_name  a.com;

        location / {
            root   html/9999;
            index  index.html index.htm;
        }
    }

然后,在C:\nginx-1.16.1\html创建目录7777,9999,把index.html 拷贝进去,然后修改得能区分开来:

<!DOCTYPE html>
<html>
<head>
<title>Welcome to 7777</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to 7777</h1>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Welcome to 9999</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to 9999</h1>
</html>

之后,平滑重启nginx

C:\nginx-1.16.1>nginx.exe -s reload

之后在浏览器器里就能看效果了:

--END-- 2019年12月14日08:22:02

Nginx配置简单基于域名的虚拟主机的更多相关文章

  1. Nginx配置之基于域名的虚拟主机

    1.配置好DNS解析 大家好,今天我给大家讲解下在Linux系统下DNS服务器的基本架设,正向解析,反向解析,负载均衡,还有从域以及一个服务器两个域或者多个域的情况. 实验环境介绍:1.RHEL5.1 ...

  2. Nginx配置多个基于域名的虚拟主机+实验环境搭建+测试

    标签:Linux 域名 Nginx 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://xpleaf.blog.51cto.com/9 ...

  3. Nginx总结(四)基于域名的虚拟主机配置

    前面讲了如何安装配置Nginx,大家可以去这里看看nginx系列文章:https://www.cnblogs.com/zhangweizhong/category/1529997.html 今天要说的 ...

  4. •搭建LAMP环境及快速部署双网站并实现基于域名的虚拟主机

    本节所讲内容: 实战:搭建LAMP环境及快速部署双网站并实现基于域名的虚拟主机 LAMP架构:??? Linux+Apache+Mysql+PHP Linux+Apache+Mysql/MariaDB ...

  5. nginx配置基于域名的虚拟主机

    其实基于域名和基于ip的虚拟主机配置是差不多的,在配置基于ip的虚拟主机上我们只需要修改几个地方就能变成基于域名的虚拟主机,一个是要修改域名,一个是host文件直接看代码 [root@localhos ...

  6. nginx基于域名的虚拟主机配置(本地分布式项目域名配置及测试方法)

    最有用的虚拟主机配置方式. 一个域名只能绑定一个ip地址,一个ip地址可以被多个域名绑定. 可以修改host文件实现域名访问. 前提:即使我们在nginx中配置基于域名的虚拟主机,也需要域名解析,即n ...

  7. 十八.搭建Nginx服务器、配置网页认证、基于域名的虚拟主机、ssl虚拟主机

    配置要求: client:192.168.4.10 proxy:192.168.4.5(eth0) 192.168.2.5(eth1) web1:192.168.2.100 web2:192.168. ...

  8. 高级运维(二):搭建Nginx服务器、用户认证、基于域名的虚拟主机、SSL虚拟主机、Nginx反向代理

    一.搭建Nginx服务器 目标: 在IP地址为192.168.4.5的主机上安装部署Nginx服务,并可以将Nginx服务器,要求编译时启用如下功能: 1> SSL加密功能 2> 设置Ng ...

  9. Nginx--服务部署、基于域名的虚拟主机配置

    一.服务部署 1.预处理 安装CentOS ,配置hosts.静态IP.设置必要的安全参数等(略) 1-1.系统环境 [root@vnx ~]# cat /etc/redhat-release Cen ...

随机推荐

  1. 应用在App Store上被拒重新提交审核流程指南

    1. 打开地址: https://itunesconnect.apple.com 2. 输入APPID和密码后,再输入绑定手机后的验证码. 3. 查看“”我的APP“”,如果显示拒绝,可能需打开Mac ...

  2. Thinkphp 配置不用输入index.php

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/u011186019/article/det ...

  3. xpath+多进程爬取八零电子书百合之恋分类下所有小说。

    代码 # 需要的库 import requests from lxml import etree from multiprocessing import Pool import os # 请求头 he ...

  4. .netcore发布时指定服务器的系统类型

    asp.net core 开发完成后发布,在IIS上面访问,直接报错  系统是windows2008 Application startup exception: System.DllNotFound ...

  5. MySQL命令操作(Linux平台)

    Linux shell 批量创建数据库/表 Shell 脚本如下: # create database and table HOST='localhost' PORT='3306' USER='roo ...

  6. git merge与git rebase区别(转载)

    这是最近看的讲的比较通俗易懂的rebase与merge的区别了 https://www.jianshu.com/p/4079284dd970

  7. 决策树——ID3

    参考网址:https://www.cnblogs.com/further-further-further/p/9429257.html ID3算法 最优决策树生成 -- coding: utf-8 - ...

  8. 学习Spring-Data-Jpa(十)---注解式方法查询之@Query、@Modifying与派生delete

    1.@Query 对于少量的查询,使用@NamedQuery在实体上声明查询是一种有效的办法,并且可以很好的工作.由于查询本身绑定到执行它们的java方法,实际上可以通过Spring-Data-Jpa ...

  9. Cramer-Rao Bounds (CRB)

    克拉美-罗界.又称Cramer-Rao lower bounds(CRLB),克拉美-罗下界. 克拉美罗界是对于参数估计问题提出的,为任何无偏估计量的方差确定了一个下限.无偏估计量的方差只能无限制的逼 ...

  10. 学到了林海峰,武沛齐讲的Day50 django

    http请求中产生两个核心对象: http请求:HttpRequest对象 http响应:HttpResponse对象 所在位置:django.http 5/8结束