实习Apache绑定多个域名

本文详细介绍了如何在Apache服务器上配置多个域名,包括修改http.conf文件中的ServerName和NameVirtualHost指令,以及设置虚拟主机的具体参数,适用于希望在同一台服务器上运行多个网站的管理员。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如何让Apache绑定多个域名

解决办法:
打开http
.conf
1,ServerName 127.0.0.1 修改成ServerName 你的IP
2#NameVirtualHost *   修改成"NameVirtualHost 你的IP"
3,在文件最后面有虚拟主机格式,




# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.

#


<VirtualHost *:80>
  ServerAdmin nettc@
163.com
  DocumentRoot 
/usr/local/www/mpc/
  ServerName scbn
.nybd.cn
  DirectoryIndex 
index.htm index.html index.php index.cgi index.pl
  DefaultLanguage zh
-CN
  AddDefaultCharset GB2312
  
<Directory "/usr/local/www/mpc/">
    Options FollowSymLinks
    AllowOverride None
    Order allow
,deny
    Allow from all
  
</Directory>

  
<IfDefine PHP>
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    php_admin_value session
.save_path "/usr/local/tmp/php/session"
    php_admin_value open_basedir 
"/usr/local/www/mpc;/usr/local/tmp/php"
  
</IfDefine>
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin 
139226688@qq.com
  DocumentRoot 
/usr/local/www/lovefan/
  ServerName bbs
.nybd.com
  DirectoryIndex 
index.htm index.html index.php index.cgi index.pl
  DefaultLanguage zh
-CN
  AddDefaultCharset GB2312
  
<Directory "/usr/local/www/lovefan/">
    Options FollowSymLinks
    AllowOverride None
    Order allow
,deny
    Allow from all
  
</Directory>

  
<IfDefine PHP>
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    php_admin_value session
.save_path "/usr/local/tmp/php/session"
    php_admin_value open_basedir 
"/usr/local/www/lovefan;/usr/local/tmp/php"
  
</IfDefine>
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin 
139226688@qq.com
  DocumentRoot 
/usr/local/www/xiaoyao/
  ServerName 51kiss
.sy850.com
  DirectoryIndex 
index.htm index.html index.php index.cgi index.pl
  DefaultLanguage zh
-CN
  AddDefaultCharset GB2312
  
<Directory "/usr/local/www/xiaoyao/">
    Options FollowSymLinks
    AllowOverride None
    Order allow
,deny
    Allow from all
  
</Directory>

  
<IfDefine PHP>
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    php_admin_value session
.save_path "/usr/local/tmp/php/session"
    php_admin_value open_basedir 
"/usr/local/www/xiaoyao;/usr/local/tmp/php"
  
</IfDefine>
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin 
139226688@qq.com
  DocumentRoot 
/usr/local/www/duandong/bbs/
  ServerName www
.nybd.cn
  DirectoryIndex 
index.htm index.html index.php index.cgi index.pl
  DefaultLanguage zh
-CN
  AddDefaultCharset GB2312
  
<Directory "/usr/local/www/duandong/bbs/">
    Options FollowSymLinks
    AllowOverride None
    Order allow
,deny
    Allow from all
  
</Directory>

  
<IfDefine PHP>
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    php_admin_value session
.save_path "/usr/local/tmp/php/session"
    php_admin_value open_basedir 
"/usr/local/www/duandong/bbs;/usr/local/tmp/php"
  
</IfDefine>
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin shhczn@
163.com
  DocumentRoot 
/usr/local/www/ddv/
  ServerName hcwl
.nybd.cn
  DirectoryIndex 
index.htm index.html index.php index.cgi index.pl
  DefaultLanguage zh
-CN
  AddDefaultCharset GB2312
  
<Directory "/usr/local/www/ddv/">
    Options FollowSymLinks
    AllowOverride None
    Order allow
,deny
    Allow from all
  
</Directory>

  
<IfDefine PHP>
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    php_admin_value session
.save_path "/usr/local/tmp/php/session"
    php_admin_value open_basedir 
"/usr/local/www/ddv;/usr/local/tmp/php"
  
</IfDefine>
</VirtualHost>
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值