apache主配置文件/usr/local/apache2.4/conf/httpd.conf
定义网站根目录
DocumentRoot "/usr/local/apache2.4/htdocs"
定义网站域名
ServerName www.example.com:80
定义虚拟主机配置文件
Include conf/extra/httpd-vhosts.conf
定义默认索引页
DirectoryIndex index.html index.php
//如果一个目录下有两个索引页,默认显示排在前面的索引页
虚拟主机概念
一台服务器可以访问多个网站,每个网站都是一个虚拟主机
任何一个域名解析到这台机器,都可以访问的虚拟主机就是默认虚拟主机
配置虚拟主机
Include conf/extra/httpd-vhosts.conf 打开主配置文件中这一行
vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
修改如下:
<VirtualHost *:80>
#ServerAdmin [email protected]
DocumentRoot "/data/wwwroot/aaa.com"
ServerName aaa.com
ServerAlias www.aaa.com www.abc.com
ErrorLog "logs/aaa.com-error_log"
CustomLog "logs/aaa.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
#ServerAdmin [email protected]
DocumentRoot "/data/wwwroot/bbb.com"
ServerName bbb.com
ServerAlias www.bbb.com
ErrorLog "logs/bbb.com-error_log"
CustomLog "logs/bbb.com-access_log" common
原文地址:http://blog.51cto.com/chenshengsheng/2097634
时间: 2024-11-05 14:43:12