zoukankan      html  css  js  c++  java
  • 一个云主机绑定多个域名

     

    假如我们有一个独立空间,地址为121.123.125.168,有两个域名www.baidu123.comwww.qq123.com。

    我们已经将www.baidu123.com绑定到121.123.125.168。

    现在我们也想将www.qq123.com放置在地址为121.123.125.168的空间里。

     

    首先,在域名提供商填写A记录

    其中Host Name填写www.qq123.com,也就是我们想绑定的第二个域名;IP Address为121.123.125.168,也就是我们的独立空间地址。

     

    其实原理比较简单,解析成功后,我们输入www.qq123.com,访问的是121.123.125.168,这时候如果我们在独立空间里的apache里设置一下,将这个地址访问指定到121.123.125.168里面的某个目录即可。

     

    这里我们举例(使用的windows服务器,linux服务器只需更改下地址格式即可),原www.baidu123.com的主目录是"D:WWW",我们想www.qq123.com使用"D:default"这个目录,那么,我们需要在apache配置文件 httpd.conf 中添加如下记录即可:

     

    <VirtualHost *:80>
    
    DocumentRoot "D:default"
    
    ServerName qq123.com
    
    ServerAlias www.qq123.com
    
    ErrorDocument 403 /errpage/missing.html
    
    ErrorDocument 404 /errpage/missing.html
    
    <IfModule mod_deflate.c>
    
    DeflateCompressionLevel 7
    
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
    
    AddOutputFilter DEFLATE css js html htm gif jpg png bmp php
    
    </IfModule>
    
    </VirtualHost>
    
     
    
    <Directory "D:default">
    
        Options FollowSymLinks
    
        AllowOverride All
    
        Order allow,deny
    
        Allow from all
    
    </Directory>

    然后重启服务器,等待解析即可。主要是等待域名服务器那边DNS解析。

    成功解析后,我们打开www.qq123.com,访问的就是121.123.125.168下的"D:default"目录;

    而我们输入www.baidu123.com,访问的就是121.123.125.168下的"D:WWW"目录。这样就实现了一个空间多个域名的问题。只不过要注意,数据库是共享mysql服务器的。整个设置和配置二级域名差不多。

     

    linuxapache配置

    <VirtualHost *:80>
    
    DocumentRoot /www/web/default
    
    ServerName qq123.com
    
    ServerAlias www.qq123.com
    
    ErrorDocument 400 /errpage/400.html
    
    ErrorDocument 403 /errpage/403.html
    
    ErrorDocument 404 /errpage/404.html
    
    ErrorDocument 405 /errpage/405.html
    
    php_admin_value open_basedir /www/web/default:/tmp
    
    <IfModule mod_deflate.c>
    
    DeflateCompressionLevel 7
    
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
    
    AddOutputFilter DEFLATE css js html htm gif jpg png bmp php
    
    </IfModule>
    
    </VirtualHost>
    
    <Directory /www/web/default>
    
        Options FollowSymLinks
    
        AllowOverride All
    
        Order allow,deny
    
        Allow from all
    
    </Directory>

    如果觉得本文有收获,记得推荐一下哦!^_^

            

  • 相关阅读:
    Linux常用命令学习2---(文件搜索命令locate find、命令搜索命令whereis which、字符串搜索命令grep、帮助命令man)
    LeetCode Perfect Squares
    华为笔试 数字转中文拼音
    二位数组 顺时针打印矩阵
    LeetCode Interleaving String
    LeetCode Coins in a Line
    LeetCode Backpack
    LeetCode Unique Paths
    LeetCode Minimum Path Sum
    腾讯模拟笔试题
  • 原文地址:https://www.cnblogs.com/52fhy/p/3979922.html
Copyright © 2011-2022 走看看