这里所有的操作都是基于win10进行的。

准备工作

要实现apache部署多站点,首先我们要找到 httpd.conf 文件 并找到如下两行代码,把其注释 # 去除。

//在我的电脑上其在184行,各有差异,可通过搜索定位
# LoadModule vhost_alias_module modules/mod_vhost_alias.so
//在我的电脑上在523行,各有差异
# Include conf/extra/httpd-vhosts.conf

找到以下部分代码(原单站点配置项,并将其删除或注释掉)

DocumentRoot "F:\test\public"
<Directory "F:\test\public">## Possible values for the Options directive are "None", "All",# or any combination of:#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews## Note that "MultiViews" must be named *explicitly* --- "Options All"# doesn't give it to you.## The Options directive is both complicated and important.  Please see# http://httpd.apache.org/docs/2.4/mod/core.html#options# for more information.#Options Indexes FollowSymLinks Includes ExecCGI## AllowOverride controls what directives may be placed in .htaccess files.# It can be "All", "None", or any combination of the keywords:#   AllowOverride FileInfo AuthConfig Limit#AllowOverride All## Controls who can get stuff from this server.#Require all granted
</Directory>

接下来打开 httpd-vhosts.conf 文件。并针对性的对其进行修改

同端口不同IP

将如下代码加入到文件中

<VirtualHost *:80>#ServerAdmin webmaster@dummy-host.example.comDocumentRoot "F:\test\ht1"ServerName 127.0.0.1<directory "F:\test\ht1"> Options FollowSymLinks AllowOverride All Require all granted </directory>   #ServerAlias www.dummy-host.example.com#ErrorLog "logs/dummy-host.example.com-error.log"#CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>#ServerAdmin webmaster@dummy-host.example.comDocumentRoot "F:\test\ht2"ServerName 127.0.0.2<directory "F:\test\ht2"> Options FollowSymLinks AllowOverride All Require all granted </directory>   #ServerAlias www.dummy-host.example.com#ErrorLog "logs/dummy-host.example.com-error.log"#CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

同IP不同端口

Listen 8080
<VirtualHost *:80>#ServerAdmin webmaster@dummy-host.example.comDocumentRoot "F:\test\ht1"ServerName 127.0.0.1<directory "F:\test\ht1"> Options FollowSymLinks AllowOverride All Require all granted </directory>   #ServerAlias www.dummy-host.example.com#ErrorLog "logs/dummy-host.example.com-error.log"#CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:8080>#ServerAdmin webmaster@dummy-host.example.comDocumentRoot "F:\test\ht2"ServerName 127.0.0.1<directory "F:\test\ht2"> Options FollowSymLinks AllowOverride All Require all granted </directory>   #ServerAlias www.dummy-host.example.com#ErrorLog "logs/dummy-host.example.com-error.log"#CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

多域名访问

我们以 同端口不同IP 的配置实现多域名访问

<VirtualHost *:80>#ServerAdmin webmaster@dummy-host.example.comDocumentRoot "F:\test\ht1"ServerName test1.test.com<directory "F:\test\ht1"> Options FollowSymLinks AllowOverride All Require all granted </directory>   #ServerAlias www.dummy-host.example.com#ErrorLog "logs/dummy-host.example.com-error.log"#CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>#ServerAdmin webmaster@dummy-host.example.comDocumentRoot "F:\test\ht2"ServerName test2.test.com<directory "F:\test\ht2"> Options FollowSymLinks AllowOverride All Require all granted </directory>   #ServerAlias www.dummy-host.example.com#ErrorLog "logs/dummy-host.example.com-error.log"#CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

修改 C:\Windows\System32\drivers\hosts文件 如下

# 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       test1.test.com127.0.0.1       test2.test.com

结束

apache多站点解决方案(同端口不同IP,同IP不同端口,多域名)相关推荐

  1. apache多站点配置+多端口配置

    Apache多站点配置 这种方法是配置不同的地址访问不同的文件夹的配置1:修改本机的hosts文件,如下: 示例:127.0.0.1 localhost127.0.0.1 www.dede.com12 ...

  2. Apache多站点配置

    闲话不多说,直接进入主题: 1.首先打开Apache安装目录下 conf/httpd.conf 文件,找到下面两行文字,把最前面的 # 号去掉,然后保存. 参考位置:128行  #LoadModule ...

  3. Linux部署Tomcat踩的坑以及解决方案【8080无法访问、日志显示XX端口被占用、修改默认端口、无法提供安全连接】

    Linux部署Tomcat踩的坑以及解决方案[8080无法访问.日志显示XX端口被占用.修改默认端口.无法提供安全连接] 8080无法访问 解压开压缩包后,执行bin目录下的 startup.sh 后 ...

  4. 如何实现同一个ip下同一个80端口部署多个网站?

    [一台服务器上如何创建多个网站?] 原理分析 本质就是Nginx监听一台服务器的80端口,使用不同的域名映射到不同的Linux文件目录(站点发布的目录) 首先就是多个域名可以解析到同一个ip地址.我们 ...

  5. Aurora8B10B IP使用 -01- 简介与端口描述

    Aurora 64B/66B IP概述 介绍 Aurora 8B/10B 内核支持 AMBA协议.AXI4-Stream 用户接口. 该内核使用 Zynq.Artix-7.Kintex-7 和 Vir ...

  6. Shell 命令行统计 apache 网站日志访问IP以及IP归属地

    Shell 命令行统计 apache 网站日志访问IP以及IP归属地 我的一个站点用 apache 服务跑着,积攒了很多的日志.我想用 shell 看看有哪些人访问过我的站点,并且他来自哪里. 因为日 ...

  7. 同一台服务器同一个IP都是80端口发布多个网站

    [一台服务器上如何创建多个网站?] 原理分析 本质就是Nginx监听一台服务器的80端口,使用不同的域名映射到不同的Linux文件目录(站点发布的目录) 首先就是多个域名可以解析到同一个ip地址.我们 ...

  8. ClassNotFoundException: org.apache.spark.AccumulatorParam 解决方案

    ClassNotFoundException: org.apache.spark.AccumulatorParam 解决方案 错误现象 : 解决方案 : 错误现象 : Job failed with ...

  9. Docker 入门系列(5)- Docker 端口映射(映射所有IP地址、映射到指定地址和指定端口、映射指定地址任意端口、查看映射端口配置)

    端口映射 映射容器内应用的服务端口到本地宿主主机 1. 从外部访问容器应用 在启动容器的时候,如果不指定对应的参数,在容器外部是无法通过网络来访问容器内的网络应用和服务的.当容器中运行一些网络应用,要 ...

最新文章

  1. Python中MySQLdb的connect的用法
  2. 要你命3000List31
  3. 扎心了!年薪100万,却还不起5000块的信用卡
  4. 【bzoj2423】最长公共子序列[HAOI2010](dp)
  5. spring 动态代理_分析动态代理给 Spring 事务埋下的坑
  6. 让这三个月来的更猛烈些吧,前端react同构项目
  7. Nginx基本数据结构之ngx_hash_wildcard_t
  8. maven私服Nexus3.2的使用
  9. CentOS7上squid的部署及两种模式(4.1版本)
  10. 自定义分区partitioner实现数据分区存储
  11. tomcat监听activemq jms配置
  12. oracle数据库管理和日常维护,oracle数据库管理与维护
  13. html如何将搜索图标放入搜索框中
  14. 卡内基梅隆大学计算机科学博士,2020年卡内基梅隆大学博士专业设置
  15. 测试过程中遇到的问题总结
  16. 用 Adobe 设置 PDF 文件在文件管理器右侧预览窗格预览
  17. 谷歌翻译Google Translate 无法使用 最新修复方法 恢复教程
  18. Win32编程---在窗体添加一个按钮
  19. 嵌入式linux驱动-LCD液晶屏驱动
  20. 51单片机硬件设计-最小系统(一)

热门文章

  1. 关于GMRES的总结
  2. 人工智能之数学基础篇—微积分
  3. unity 5.x从入门到精通_Unity学习中值得收藏的学习资料(书籍)与博客
  4. 海外新闻通稿发布时常见四大误区
  5. 如何在应用中跳转到 设置系统锁屏的界面
  6. 小鼠大脑解剖图分区_关于小鼠脑的各个功能区
  7. 罗杰斯RT/duroid® 5880高频电路板材参数
  8. 旋元佑进阶语法_简体
  9. 怎么把ppt转成pdf?PPT转PDF简单方法分享
  10. PCL ICP使用OMP加速(ICP_OMP)