欢迎加入EUCMS官方QQ交流群,与更多EUCMS用户一起讨论,共同发财!

QQ群:1222386
> 资讯中心 >> 建站技术 >>正文
教你如何用apache同ip多站点架设
2020-12-03 1207 收藏
这里是指同一IP绑定N个域名,有二种方式实现
方法1、仅修改httpd.conf
假设二个域名bbs.xxx.com与blog.xxx.com
打开httpd.conf
将文件拖到最下面,加上


view plaincopy to clipboardprint?
 
 ServerName bbs.xxx.com   #域名  
 DocumentRoot "F:/website/bbs"   #该域名对应的目录地址    
   #该节点是配置权限、默认首页啊等等东东。  
 Options FollowSymLinks IncludesNOEXEC Indexes  
 DirectoryIndex  index.php   
 AllowOverride None   
 Order Deny,Allow   
 Allow from all      
 
 
 
 
 ServerName blog.xxx.com  
 DocumentRoot "D:/PHPSite/wordpress"  
   
 Options FollowSymLinks IncludesNOEXEC Indexes  
 DirectoryIndex  index.php   
 AllowOverride None   
 Order Deny,Allow   
 Allow from all   
 
 


 ServerName bbs.xxx.com   #域名
 DocumentRoot "F:/website/bbs"   #该域名对应的目录地址 
   #该节点是配置权限、默认首页啊等等东东。
 Options FollowSymLinks IncludesNOEXEC Indexes
 DirectoryIndex  index.php
 AllowOverride None
 Order Deny,Allow
 Allow from all   




 ServerName blog.xxx.com
 DocumentRoot "D:/PHPSite/wordpress"

 Options FollowSymLinks IncludesNOEXEC Indexes
 DirectoryIndex  index.php
 AllowOverride None
 Order Deny,Allow
 Allow from all



重启apache,就OK啦。当然你要修改你的hosts文件。

方法2、修改\PhpServer\Apache2.2\conf\extra\httpd-vhosts.conf
直接将上面一段copy到httpd-vhosts.conf的最后即可。
实际上看名字就知道httpd-vhosts.conf是一个虚拟站点配置集中地,方便管理。
也就是如下:
view plaincopy to clipboardprint?
#  
# Virtual Hosts  
#  
# If you want to maintain multiple domains/hostnames on your  
# machine you can setup VirtualHost containers for them. Most configurations  
# use only name-based virtual hosts so the server doesn't need to worry about  
# IP addresses. This is indicated by the asterisks in the directives below.  
#  
# Please see the documentation at   
#  
# for further details before you try to setup virtual hosts.  
#  
# You may use the command line option '-S' to verify your virtual host  
# configuration.  
 
#  
# Use name-based virtual hosting.  
#  
NameVirtualHost *:80  
 
#  
# VirtualHost example:  
# Almost any Apache directive may go into a VirtualHost container.  
# The first VirtualHost section is used for all requests that do not  
# match a ServerName or ServerAlias in any block.  
#  
 
 
 
 ServerName bbs.xxx.com   #域名  
 DocumentRoot "F:/website/bbs"   #该域名对应的目录地址    
   #该节点是配置权限、默认首页啊等等东东。  
 Options FollowSymLinks IncludesNOEXEC Indexes  
 DirectoryIndex  index.php   
 AllowOverride None   
 Order Deny,Allow   
 Allow from all      
 
 
 
 
 
 ServerName blog.xxx.com  
 DocumentRoot "D:/PHPSite/wordpress"  
   
 Options FollowSymLinks IncludesNOEXEC Indexes  
 DirectoryIndex  index.php   
 AllowOverride None   
 Order Deny,Allow   
 Allow from all   
 
 

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
#
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any block.
#



 ServerName bbs.xxx.com   #域名
 DocumentRoot "F:/website/bbs"   #该域名对应的目录地址 
   #该节点是配置权限、默认首页啊等等东东。
 Options FollowSymLinks IncludesNOEXEC Indexes
 DirectoryIndex  index.php
 AllowOverride None
 Order Deny,Allow
 Allow from all   





 ServerName blog.xxx.com
 DocumentRoot "D:/PHPSite/wordpress"

 Options FollowSymLinks IncludesNOEXEC Indexes
 DirectoryIndex  index.php
 AllowOverride None
 Order Deny,Allow
 Allow from all



重启apache。
如果不行的话,看你的httpd.conf是否启用了vhost
打开httpd.conf,找到
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
看是否启用,即去掉Include conf/extra/httpd-vhosts.conf前的#
重启apache,爽去吧。

 

你觉得这篇文章怎么样?

0 0
参与讨论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
成品站
购买流程
  • 注册会员
  • 选择网站模板
  • 免费开通试用
  • 绑定域名试用
  • 选择套餐
  • 付款转正
  • 域名正式生效
  • 网站正式上线
  • 分站:
    扫描关注微信

    扫描加微信

    13852154923

    0516-66628816

    工作日 9:00-12:00 13:30-18:00
    周六及部分节假日提供值班服务
    2186398
    群:1222386
    做网站网站制作网络公司网站建设怎么做网站北京上海广州深圳南京合肥芜湖新疆甘肃济南
    Copyright@2003-2025 徐州亿优网架钢结构工程有限公司版权所有 Powered by EUCMS-v6.3 | 网站地图 苏ICP备19019550号