您的位置:首页 > 运维架构 > Apache

apache配置虚拟机

2013-09-26 16:43 204 查看
1、打开apache安装目录下的conf/httpd.conf

搜索Virtual hosts,可以看到:

#Virtual hosts

#Include conf/extra/httpd-vhosts.conf

意思是启用虚拟主机的设置文件httpd-vhosts.conf,虚拟主机的设置都在这个文件下

设置,改为:

#Virtual hosts

Include conf/extra/httpd-vhosts.conf

2、打开apache安装目录下的conf/extra/httpd-vhosts.conf

搜索<VirtualHost *:80>可看到

<VirtualHost *:80>

    ServerAdmin webmaster@dummy-host.example.com

    DocumentRoot " c:/Apache24/docs/dummy-host.example.com"

    ServerName dummy-host.example.com

    ServerAlias www.dummy-host.example.com

    ErrorLog "logs/dummy-host.example.com-error.log"

    CustomLog "logs/dummy-host.example.com-access.log" common

</VirtualHost>

 

修改为:

<VirtualHost 127.0.0.2:80>

<Directory "D:/wamp/www/test">

Options FollowSymLinks IncludesNOEXEC Indexes

DirectoryIndex index.html index.htm index.php

AllowOverride Options FileInfo

Order Deny,Allow 

Allow from all

</Directory>

    ServerAdmin webmaster@dummy-host.example.com

    DocumentRoot "D:/wamp/www/test"

    ServerName dummy-host.example.com

    ServerAlias www.dummy-host.example.com

    ErrorLog "logs/dummy-host.example.com-error.log"

    CustomLog "logs/dummy-host.example.com-access.log" common

</VirtualHost>

重新启动服务器

在D:/wamp/www/test 下随便新建一个php文件,如test.php

在浏览器中输入127.0.0.2就可以直接访问了。

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  apache php 虚拟主机