Mac启动Apache之后访问localhost提示403 Forbidden

最近学习PHP需要, 需要在Mac上启动Apache, 启动后出现访问localhost之后提示

Forbidden

You don't have permission to access / on this server

网上百度了很多解决方法, 包括修改User Group, Directory块与新建{用户名}.conf, 都不管用.

最后试着恢复原先的设置, 并且将DocumentRoot与Directory路径修改回默认的路径:

#
# 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 "/Library/WebServer/Documents/"
<Directory "/Library/WebServer/Documents/">

终端: 停止Apache

sudo apachectl stop

终端: 启动Apache

sudo apachectl start

之后访问localhost, 成功!
访问域名

访问ip

猜你喜欢

转载自blog.csdn.net/dongzhensong/article/details/78328022