通过修改httpd.conf来生成多个二级域名访问

查找 NameVirtualHost *:80 去掉前面的#

在文中最底下编辑

<VirtualHost *:80>
    ServerAdmin [email protected]  邮箱
    DocumentRoot /var/www/html/test   在网站根目录下新建一个目录取名 test  本人的网站根目录是/var/www/html/
    ServerName test.域名.com  
    DirectoryIndex index.htm index.html index.php
</VirtualHost>

每次多编辑一个上面的内容 就多设置一个二级域名

<VirtualHost *:80>
    ServerAdmin [email protected]  邮箱
    DocumentRoot /var/www/html/shop  在网站根目录下新建一个目录取名shop  
    ServerName shop.域名.com  
    DirectoryIndex index.htm index.html index.php
</VirtualHost>

重启一下Apache

现在去修改域名解析 让test.域名.com  和 shop.域名.com的IP指向这台服务器

OK 生效就可以访问了 比如我的网站根目录下装的是Discuz  根目录下test 装的是 phpwind 根目录下的shop 装的是ECshop

哈哈 是不是很神奇!!!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章