2.2和2.4配置虚拟主机多少有点不一样,今天给大家总结写,方便大家配置。
1.编辑httpd (以下为我自己的apache路径)
- 注释以下代码
(开启虚拟主机时,最好关闭主文件中的虚拟主机,否则输入的域名会被解析到主配置中的虚拟目录中)
image.png
- 去掉前面注释
(开启虚拟主机)
image.png
2.编辑httpd-vhost.conf中配置想新增的站点 (以下为我自己的apache路径)


代码如下
apache2.4权限配置
<VirtualHost *:80>
DocumentRoot "F:/phpdemo"
ServerName www.ct.com
DirectoryIndex index.php
<Directory "F:/phpdemo">
Options Indexes FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "F:/demo"
ServerName www.123.com
DirectoryIndex index.php
<Directory "F:/demo">
Options Indexes FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
apache2.2权限配置

3.编辑hosts


修改apache配置文件是,记住重启apache!!!!
觉得有用的小伙伴点个关注和小红心就行😄,么么哒。
网友评论