设置本地虚拟域名windows+apache

时间:2024-09-14 10:36:38

C:\WINDOWS\system32\drivers\etc\hosts

在这个文件中 最下面添加。

  1. 127.0.0.1   localhost.com
  2. 127.0.0.1   cho.com
  3. 127.0.0.1   devwo.com
  4. 127.0.0.1   phpmyadmin.com

信息来自:http://blog.sina.com.cn/s/blog_7347580d0100w88d.html

D:\wamp\bin\apache\Apache2.2.17\conf\extra\httpd-vhosts.conf

添加与hosts 相应的 映射

  1. #
  2. # Virtual Hosts
  3. #
  4. # If you want to maintain multiple domains/hostnames on your
  5. # machine you can setup VirtualHost containers for them. Mostconfigurations
  6. # use only name-based virtual hosts so the server doesn't need toworry about
  7. # IP addresses. This is indicated by the asterisks in thedirectives below.
  8. #
  9. # Please see the documentation at
  10. #<URL:http://httpd.apache.org/docs/2.2/vhosts/>
  11. # for further details before you try to setup virtual hosts.
  12. #
  13. # You may use the command line option '-S' to verify your virtualhost
  14. # configuration.
  15. #
  16. # Use name-based virtual hosting.
  17. #
  18. NameVirtualHost *:80
  19. #
  20. # VirtualHost example:
  21. # Almost any Apache directive may go into a VirtualHostcontainer.
  22. # The first VirtualHost section is used for all requests that donot
  23. # match a ServerName or ServerAlias in any<VirtualHost> block.
  24. #
  25. <VirtualHost *:80>
  26. ServerAdminwebmaster@dummy-host.hleclerc-PC.ingenidev
  27. DocumentRoot"C:/Dev/Projets/WampServer2-64b/install_files_wampserver2/bin/apache/Apache2.2.17/docs/dummy-host.hleclerc-PC.ingenidev"
  28. ServerNamedummy-host.hleclerc-PC.ingenidev
  29. ServerAliaswww.dummy-host.hleclerc-PC.ingenidev
  30. ErrorLog"logs/dummy-host.hleclerc-PC.ingenidev-error.log"
  31. CustomLog"logs/dummy-host.hleclerc-PC.ingenidev-access.log" common
  32. </VirtualHost>
  33. <VirtualHost *:80>
  34. ServerAdminwebmaster@dummy-host2.hleclerc-PC.ingenidev
  35. DocumentRoot"C:/Dev/Projets/WampServer2-64b/install_files_wampserver2/bin/apache/Apache2.2.17/docs/dummy-host2.hleclerc-PC.ingenidev"
  36. ServerNamedummy-host2.hleclerc-PC.ingenidev
  37. ErrorLog"logs/dummy-host2.hleclerc-PC.ingenidev-error.log"
  38. CustomLog"logs/dummy-host2.hleclerc-PC.ingenidev-access.log" common
  39. </VirtualHost>
  40. /*-----------------------------*/
  41. <VirtualHost *:80>
  42. Options None
  43. ServerAdmin cho.com
  44. DocumentRoot E:\PHP\PHPProject\inpiao
  45. ServerName cho.com
  46. ErrorLog logs/phpmyadmin.com-error_log
  47. CustomLog logs/phpmyadmin.com-access_log common
  48. php_admin_value open_basedir "E:\PHP\PHPProject\inpiao"
  49. </VirtualHost>
  50. <VirtualHost *:80>
  51. Options None
  52. ServerAdmin devwo.com
  53. DocumentRoot E:\PHP\PHPProject\devwo
  54. ServerName devwo.com
  55. ErrorLog logs/phpmyadmin.com-error_log
  56. CustomLog logs/phpmyadmin.com-access_log common
  57. php_admin_value open_basedir "E:\PHP\PHPProject\devwo"
  58. </VirtualHost>
  59. <VirtualHost *:80>
  60. Options None
  61. ServerAdmin localhost.com
  62. DocumentRoot E:\PHP\PHPProject
  63. ServerName localhost.com
  64. ErrorLog logs/phpmyadmin.com-error_log
  65. CustomLog logs/phpmyadmin.com-access_log common
  66. php_admin_value open_basedir "E:\PHP\PHPProject"
  67. </VirtualHost>
  68. <VirtualHost *:80>
  69. Options None
  70. ServerAdmin phpmyadmin.com
  71. DocumentRoot D:\wamp\apps\phpmyadmin3.3.9
  72. ServerName phpmyadmin.com
  73. ErrorLog logs/phpmyadmin.com-error_log
  74. CustomLog logs/phpmyadmin.com-access_log common
  75. php_admin_value open_basedir "D:\wamp\apps\phpmyadmin3.3.9"
  76. </VirtualHost>

最后在 \conf\httpd.conf 中  开启
# Virtual hosts
Include conf/extra/httpd-vhosts.conf