自己的vps上放了别人的网站,那怎么样让自己的网站和别人的网站能同时被访问呢?需要使用apache的虚拟主机配置。

配置httpd.conf文件

比如原来是这种只是指向一个目录的配置

DocumentRoot "/opt/lampp/htdocs/ppe112"
<Directory "/opt/lampp/htdocs/ppe112">
#
# 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/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes #
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride None
# since XAMPP 1.4:
AllowOverride All #
# Controls who can get stuff from this server.
#
Require all granted
</Directory>

把这段话变成

<VirtualHost 198.199..XXX>       #这里填主机的ip地址
ServerName www.AAA.com
DocumentRoot "/opt/lampp/htdocs/AAA"
<Directory "/opt/lampp/htdocs/AAA">
#
# 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/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes #
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride None
# since XAMPP 1.4:
AllowOverride All #
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
</VirtualHost> <VirtualHost 198.199..XXX> #这里填主机的ip地址
ServerName www.BBB.com
DocumentRoot "/opt/lampp/htdocs/BBB"
<Directory "/opt/lampp/htdocs/BBB">
#
# 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/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes #
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride None
# since XAMPP 1.4:
AllowOverride All #
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
</VirtualHost>

这样就实现了AAA网站和BBB网站同时在服务器上共存,外部两个域名指向同一个ip,内部解析到不同服务器目录的操作。

PS:这里这里只能正常访问www.AAA.com  www.BBB.com这两个,如果要直接访问AAA.com  BBB.com 也需要如上再配置一遍。

apache单ip多域名多目录配置的更多相关文章

  1. apache一个IP多个站点的配置方法

    在日常的网站发布中很多情况下都无法做到一个IP对应一个站点,在IP4的情况下IP的资源是相对有限的.然而作为最流行的Apache自然也考虑到这种情况,那么接下来看看apache服务器怎么配置一个IP多 ...

  2. 关于apache下同IP多域名支持HTTPS和80跳转HTTPS的配置

    httpd-ssl的配置: Listen 443 NameVirtualHost *:443 AddType application/x-x509-ca-cert .crt AddType appli ...

  3. apache单ip配置多端口多站点

    1.修改 /etc/httpd/conf/httpd.conf 添加一个Listen,如: Listen 80 Listen 8001 Listen 8002 2.添加一个VirtualHost #v ...

  4. nginx分区域名转发 tp5域名分目录配置

    需求 本来我们一般情况下都是域名abc.com解析到网站的根目录/root/public这种.但是客户突然提出了一个奇葩的需求,客户要求以后可能网站会增多,需要增加分区的功能,比如abc.com/wh ...

  5. [环境配置] 如何为Apache绑定多IP多域名

    在Apache服务器上绑定方法比较简单,主要因为Apache是个开源独立的服务器软件,而且支持跨平台安装和配置,支持丰富的API扩展,所以很多人对Apache的好感要甚于IIS,Apache的优点就不 ...

  6. apache虚拟目录配置实例

    apache虚拟目录配置实例 一.首先,开启虚拟主机配置 在文件httpd.conf中找到: include conf/extra/httpd-vhosts.conf #开启 二.对httpd-vho ...

  7. wamp多网站配置for window 本地测试 单Ip

    网上有很多WAMP集成环境下单IP多域名虚拟主机配置的文章,自己总结了有用方法记录下来 简单的介绍一下我的系统环境:window xp  和 wamp apache2.2.8 ------------ ...

  8. linux apache虚拟主机配置(基于ip,端口,域名)

    配置环境: linux版本:Centos6.4 httpd版本: [root@centos64Study init.d]# pwd/etc/init.d[root@centos64Study init ...

  9. centos7 Apache 2.4.6 多域名多网站配置

    Apache 2.4.6 多域名多网站配置 在/etc/httpd/conf 下 编辑 vim httpd.conf 添加:ServerName 外网IP 并注释 #DocumentRoot &quo ...

随机推荐

  1. Meteor check

    check方法用于检查参数或类型是否匹配模式. 安装check包 打开命令提示符窗口,并安装该软件包. C:\Users\Administrator\Desktop\meteorApp>mete ...

  2. CSS浮动通俗讲解

    首先要知道,div是块级元素,在页面中独占一行,自上而下排列,也就是传说中的流.如下图: 可以看出,即使div1的宽度很小,页面中一行可以容下div1和div2,div2也不会排在div1后边,因为d ...

  3. 学习Centos 7的笔记

    Step-1 yum install epel-release && yum clean all && yum update –y &&  yum -y ...

  4. day5-WordCount

    1.   wordcount示例开发 1.1. wordcount程序整体运行流程示意图 map阶段: 将每一行文本数据变成<单词,1>这样的kv数据 reduce阶段:将相同单词的一组k ...

  5. 【Mongodb教程 第十一课 】MongoDB 聚合

    聚合操作过程中的数据记录和计算结果返回.聚合操作分组值从多个文档,并可以执行各种操作,分组数据返回单个结果.在SQL COUNT(*)和group by 相当于MongoDB的聚集. aggregat ...

  6. c语言实现输出一个数的每一位

    比方输入1234.在屏幕上打印出1 2 3 4 代码展示: 方法一: #define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #includ ...

  7. WebService(2)-XML系列之用Stax操作Xml

    源代码下载:链接: http://pan.baidu.com/s/1ntL1a7R password: rwp1 本文主要讲述:利用Stax处理xml文档 一.读取xml 1.基于光标的查找 核心:X ...

  8. ==和equals的差别

    == 和 Equals 的差别 1. == 是一个运算符. 2.Equals则是string对象的方法.能够.(点)出来. 我们比較无非就是这两种 1.基本数据类型比較 2.引用对象比較 1.基本数据 ...

  9. 启动两个Tomcat的方法

     由于项目需要,所以要启动两个工程,但是又不能用一个Tomcat,于是就琢磨起了怎么启动两个Tomcat 1:首先,conf/server.xml要把HTTP的端口改成不一致的,我一个是8088,一个 ...

  10. Source code for redis.connection

    redis.connection — redis-py 2.10.5 documentation http://redis-py.readthedocs.io/en/latest/_modules/r ...