sudo vi /etc/apache2/httpd.conf
取消它的注释(#)LoadModule php7_module libexec/apache2/libphp7.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
文件配置修改如下列
"/Users/xwz/PhpstormProjects"文件路径:非桌面文件
#new paths
#AllowOverride none
AllowOverride All
#Require all denied
Require all granted
Allow from all
Options FollowSymLinks
#DocumentRoot "/Library/WebServer/Documents"
DocumentRoot "/Users/xwz/PhpstormProjects"
#
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
#Options FollowSymLinks Multiviews
Options FollowSymLinks Multiviews Indexes
MultiviewsMatch Any
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
#AllowOverride None
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
#
#AllowOverride None
AllowOverride All
#Options None
#Options Indexes MultiViews
Options Indexes FollowSymLinks
Require all granted
Allow from all
Allow from 127.0.0.1
Order Deny,Allow
反复认真读httpd.conf这个文件,注意看注释;
2.列坑
(1)forbidden 。。。。。
You don’t have permission to access / on this server
Server unable to read htaccess file, denying access to be safe
httpd.conf配置不对,可能文件路径不对,或文件是桌面文件
(2)URL 不在服务内,
要新建默认的index.php文件;
可以同目录下新建HTML文件运行试试;非点浏览器运行
有些忘了。。。
待补充
效果如下: