1修改C:\Windows\System32\drivers\etc\hosts文件
在最后添加
127.0.0.1 ummanager.com.cn2修改D:\myenv\Apache2.2\conf\httpd.conf文件
添加
Include "D:\myenv\Apache2.2\conf\extra\httpd-vhosts.conf" 3修改D:\myenv\Apache2.2\conf\exta\httpd-vhosts.conf文件
复制一下最后上面的<VirtualHost *:80></VirtualHost>,并将其修改
其中
ServerName必须与第一步添加的一致<pre name="code" class="html">DocumentRoot是你项目所在的绝对路径<VirtualHost *:8080>
ServerAdmin webmaster@dummy-host.lhw
DocumentRoot "D:/myenv/Apache2.2/htdocs/umlxe_manager/"
ServerName ummanager.com.cn
ServerAlias www.ummanager.com.cn
ErrorLog "logs/dummy-host.lhw-error.log"
CustomLog "logs/dummy-host.lhw-access.log" common
</VirtualHost>
因为我用的是8080端口,所以端口号也改了,并在httpd-vhosts.conf文件中添加
NameVirtualHost *:8080
4修改访问默认的首页,修改D:\myenv\Apache2.2\conf\httpd.conf文件
<IfModule dir_module>
DirectoryIndex index.html
DirectoryIndex index.php
</IfModule>
5重启apache
访问http://ummanager.com.cn:8080/index.php成功
本文介绍如何通过修改hosts文件和Apache配置文件实现本地域名访问。包括添加域名映射、配置虚拟主机、更改默认首页及重启服务等步骤。
3492

被折叠的 条评论
为什么被折叠?



