mac本地安装php环境后,浏览器访问 http://localhost/
403 Forbidden You don’t have permission to access / on this server;
或者找不到 webserver 的路径
我的本地环境是:
PHP 7.1.16
Apache/2.4.33 (Unix)
如果你也遇到这种情况,可以参考一下我的步骤:
-
在用户名下创建文件夹Sites
-
切换 root 用户下
su root
输入自己的密码
-
打开 httpd.conf 文件
vi /etc/apache2/httpd.conf
-
找到
LoadModule userdir_module libexec/apache2/mod_userdir.so
并将 # 去掉
-
找到 DocumentRoot 修改成自己的路径
DocumentRoot "/Users/ybaog/Public/Sites" <Directory "/Users/ybaog/Public/Sites">
-
找到
Options FollowSymLinks Multiviews
修改成
Options FollowSymLinks Multiviews Index
保存退出
-
创建新的文件夹 /etc/apache2/users/ybaog.conf
在文件中输入<Directory "/Users/ybaog/Public/Sites/"> Options Indexes MultiViews AllowOverride All Order allow,deny Allow from all Require all granted </Directory>
-
重启apache服务器
apachectl restart