Apache虚拟主机VirtualHost设置

一、配置端口、打开虚拟机配置文件

$root:vi /usr/local/apache2/conf/httpd.conf

#监听8866端口
Listen 8866;  
#去掉下面注释
# Virtual hosts
Include conf/extra/httpd-vhosts.conf  

二、编辑/conf/extra/httpd-vhost.conf文件,加入:

$root:vi /usr/local/apache2/conf/extra/httpd-vhost.conf

<VirtualHost *:8866>  
    ServerAdmin webmaster@demo.com
    DocumentRoot "\home\youwebroot"
    ServerName admin.sct.com
    ErrorLog "logs/demo.com-error.log"
    CustomLog "logs/demo.com-access.log" common
</VirtualHost>  

三、重启服务

$root:apachectl restart

四、查看端口

$root:netstat -ano | grep 8866 tcp

0      0 :::8866    :::*   LISTEN      off (0.00/0/0)  
comments powered by Disqus