当前位置:Gxlcms > PHP教程 > 关于php之Apache配置虚拟主机

关于php之Apache配置虚拟主机

时间:2021-07-01 10:21:17 帮助过:29人阅读

Apache版本以2.4为例

1、修改httpd.conf

把下面第二行的#去掉,启动虚拟主机配置

  1. # Virtual hosts # Include conf/extra/httpd-vhosts.conf

2、配置httpd-vhost.conf

这里使用了8081端口,配置了两个虚拟主机,DocumentRoot不能含有中文目录

  1. <VirtualHost *:8081>
  2. ServerName localhost
  3. DirectoryIndex index.php
  4. DocumentRoot "D:\Work\php\Apache24\htdocs"
  5. <Directory "D:\Work\php\Apache24\htdocs">
  6. Options Indexes FollowSymLinks
  7. AllowOverride None
  8. Order allow,deny
  9. Allow from all
  10. </Directory>
  11. </VirtualHost>
  12. <VirtualHost *:8081>
  13. ServerName www.aa.com
  14. DirectoryIndex index.php
  15. DocumentRoot "E:\php\PhpProjectBase"
  16. <Directory "E:\php\PhpProjectBase">
  17. Options Indexes FollowSymLinks
  18. AllowOverride None
  19. Order allow,deny
  20. Allow from all
  21. </Directory>
  22. </VirtualHost>

3、etc/hosts配置

  1. 127.0.0.1 localhost127.0.0.1 www.aa.com

4、重启Apache服务

如果此时虚拟主机仍不能访问,配置httpd.conf中以下项

  1. <Directory />
  2. AllowOverride none #Require all denied</Directory>

以上就是关于php之Apache配置虚拟主机的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行