jianghuchuanke 2019-11-19
建议在主配置文件中增加一句 Include conf/vhosts/*.conf
然后就在vhosts目录下添加虚拟主机配置文件
在配置前打开NameVirtualHost *:80
注释,注意此处要与Apache主配置监听端口一致
<VirtualHost *:80> ServerAdmin [email protected] #站点邮箱 DocumentRoot /www/docs/dummy-host.example.com #访问目录 ServerName dummy-host.example.com #域名 ErrorLog logs/dummy-host.example.com-error_log #错误日志目录 CustomLog logs/dummy-host.example.com-access_log common #访问日志目录 <Directory /var/www/html/web1> 此处可以覆盖主配置文件中的Directory部分,配置规则完全按照Directory来 </Directory> </VirtualHost>
Listen 127.0.0.1:81 <VirtualHost 127.0.0.1:81> DocumentRoot "/www/docs/dummy-host.example.com" ServerName 127.0.0.1:81 </VirtualHost>