1.修改http.conf文件打开虚拟主机设置
vi /usr/local/conf/httpd.conf
找到如下去掉注释
...
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
...

2.配置http_vhost.conf文件
vi /usr/local/apache/conf/extra/httpd-vhosts.conf
如下配置了2个虚拟主机分别是myisam.com  innodb.com
NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin ngnix@qq.com
    DocumentRoot "/usr/local/apache2.2.22/htdocs/myisam.com"
    ServerName myisam.com
    ServerAlias www.myisam.com
    ErrorLog "logs/myisam.com-error_log"
    CustomLog "logs/myisam.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin ngnix@qq.com
    DocumentRoot "/usr/local/apache2.2.22/htdocs/innodb.com"
    ServerName innodb.com
    ErrorLog "logs/innodb.com-error_log"
    CustomLog "logs/innodb.com-access_log" common
</VirtualHost>

3.查看站点目录权限
vi /usr/local/conf/httpd.conf
<Directory "/usr/local/apache2.2.22/htdocs"> 
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
 如果上面虚拟主机设置在其他路径下,例如/var/www则上面要改成
<Directory "/var/www"> 
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

4.检测虚拟主机
 /usr/local/bin/apachectl  -t              检查配置文件
/usr/local/bin/apachectl -S               查看虚拟主机情况
 /usr/local/bin/apachectl  graceful        平滑启动
[root@test htdocs]# netstat -lnt |grep 80  检测端口
tcp        0      0 :::80                       :::*                        LISTEN     
[root@test htdocs]# ps -ef|grep httpd      检查httpd服务
root      2775     1  0 07:01 ?        00:00:00 /usr/local/apache2.2.22/bin/httpd -k start
daemon    4481  2775  0 12:28 ?        00:00:00 /usr/local/apache2.2.22/bin/httpd -k start
daemon    4482  2775  0 12:28 ?        00:00:00 /usr/local/apache2.2.22/bin/httpd -k start
daemon    4484  2775  0 12:28 ?        00:00:00 /usr/local/apache2.2.22/bin/httpd -k start
daemon    4486  2775  0 12:28 ?        00:00:00 /usr/local/apache2.2.22/bin/httpd -k start
daemon    4566  2775  0 12:28 ?        00:00:00 /usr/local/apache2.2.22/bin/httpd -k start
root      4630  3304  0 12:45 pts/1    00:00:00 grep httpd
[root@test htdocs]# lsof -i tcp:80          检查80端口对应的服务
COMMAND  PID   USER   FD   TYPE DEVICE SIZE NODE NAME
httpd   2775   root    3u  IPv6  12083       TCP *:http (LISTEN)
httpd   4482 daemon    3u  IPv6  12083       TCP *:http (LISTEN)
httpd   4484 daemon    3u  IPv6  12083       TCP *:http (LISTEN)
httpd   4486 daemon    3u  IPv6  12083       TCP *:http (LISTEN)
httpd   4566 daemon    3u  IPv6  12083       TCP *:http (LISTEN)