方法一:
- 1 打开 应用程序->XAMPP->xamppfiles->etc->httpd.conf 文档
- 2
commond+f
搜索htdocs
,搜到如下结果
# DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs" <Directory "/Applications/XAMPP/xamppfiles/htdocs">
- 3 修改DocumentRoot和Directory中的路径为你想要的路径,两个的路径要一样
方法二:
打开xampp -> Manage Servers -> Apache Web Server -> Configure -> Open Conf File ,之后同方法1的第二步
修改完之后在终止apache服务的时候可能会出现如下错误:
Stopping Apache Web Server...
Exit code: 8
Stdout:
apache config test fails, aborting
Stderr:
AH00526: Syntax error on line 229 of /Applications/XAMPP/xamppfiles/etc/httpd.conf:
DocumentRoot '/Applications/XAMPP/xamppfiles/\xe2\x80\x9c/Users/****/PhpstormProjects\xe2\x80\x9c' is not a directory, or is not readable
可以看到其中出现 \xe2\x80\x9c 的错误,主要是由于在修改DoucmentRoot时出现中文引号的原因,
“/Users/mac-user/Sites/domain/httpdocs”
This should be:
"/Users/mac-user/Sites/domain/httpdocs"
可参考
https://stackoverflow.com/questions/27843813/apache-prefixing-path-to-virtual-hosts-path
https://stackoverflow.com/questions/22951499/mac-os-x-xampp-access-forbidden