Apache2 配置虚拟域

By | 2018-11-26

以下配置范例基于单个IP多个虚拟域名:

编辑 /etc/apache2/httpd.conf

NameVirtualHost *:80

<VirtualHost *:80>
ServerName *                               <– 查询不到的域名全部读取 /var/www目录下的页面
DocumentRoot /var/www/
DirectoryIndex index.html              <– 默认文件为 index.html
</VirtualHost>

<VirtualHost *:80>
ServerName abook.abc.com         <– 虚拟域名
DocumentRoot /var/www/ab/         <– 虚拟域名的页面目录
Alias /icons/ /var/www/ab/icons/     <– 该配置为读取icons目录时能正确读取虚拟域名目录下的icons
DirectoryIndex index.php               <– 默认文件为 index.php
</VirtualHost>

發佈留言