apache一个IP绑定多个域名,实现多个网站

用ServerAlias

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /www/kuigg.com
ServerName kuigg.com
ServerAlias  www.kuigg.com  abc.kuigg.com
</VirtualHost>

或者用下面的笨方法

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /www/kuigg.com
ServerName kuigg.com
</VirtualHost>

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /www/kuigg.com
ServerName www.kuigg.com
</VirtualHost>

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /www/kuigg.com
ServerName abc.kuigg.com
</VirtualHost>

同一个域名,同一个网站空间,多个虚拟主机

httpd.conf文件的如下注释去掉

LoadModule vhost_alias_module modules/mod_vhost_alias.so

httpd-vhosts.conf里添加另一个虚拟主机,最后形成

<VirtualHost *:80>
  ServerName blog.oaphy.com
  ServerAlias blog.oaphy.com www.oaphy.com oaphy.com
 # DocumentRoot "${INSTALL_DIR}/www"
  DocumentRoot "C:/wamp64/www"
  <Directory "${INSTALL_DIR}/www">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
   # Require local
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName en.oaphy.com
  DocumentRoot "C:/wamp64/www/english-oaphy"
  <Directory "C:/wamp64/www/english-oaphy">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
   # Require local
  </Directory>
</VirtualHost>

用wordpress的多站点功能

先关闭所有插件,仪表盘就会出现配置网络,按步骤配置即可。

发表评论