最近在自学LAMP,在Apache中尝试着开启虚拟主机的时候,遇到了挺多麻烦的,这里也顺便总结一下,在Apache中开启虚拟主机的时候,主要有下面几个步骤: 1.新建一个文件夹作为虚拟主机,用来存储网站资源例如我是在Apache目录下新建了一个 htdocs_v 文件夹,里头新建了一个php文件,内容如下: <?php echo 'this is the first virtual host'; ?> 2.在配置文件中开启虚拟主机:打开Apache/conf/httpd.conf文件,修改如下
今天为了做项目,在Apache中配置了项目域名,成功访问.但是忽然发现要访问localhost突然出现The requested URL / was not found on this server. 出现这种情况在网上查了下是由于开启 httpd.conf 文件中 Include conf/extra/httpd-vhosts.conf 导致的,只要把它注释掉就可以了,我试了一下确实可以,但是我的虚拟域名还得要啊. 于是就想给 localhost 配置虚拟域名,但是配完之后也没有出现预期的效果
<VirtualHost 127.0.0.2:80> ServerName www.xylilun.cn DocumentRoot E:/www/ylll <Directory E:/www/ylll> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> http://randomclan.blog.163.com/blog/static/14530098
开放访问权限 D:\wamp\bin\apache\apache2.4.9\conf 里的 httpd.conf 搜索www 把 Require local 改为 Require all granted DocumentRoot "d:/wamp/www/" ## Each directory to which Apache has access can be configured with respect# to which services and features are