1. 打开修改/etc/apache2/httpd.conf内容, 查找如下:
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
#
# 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
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
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
原来Apache根目录是/Library/WebServer/Documents, 现改为/Users/username/phpSites, 如下:
DocumentRoot /Users/username/phpSites
<Directory /Users/username/phpSites>
Options Indexes MultiViews
# apache 2.2
# AllowOverride All
# Order allow,deny
# Allow from 127.0.0.1
# apache 2.4
Require local
</Directory>
Apache运行命令:
sudo apachectl start //开始
sudo apachectl restart //重启
sudo apachectl stop //停止
参考:http://yansu.org/2013/12/11/lamp-in-mac.html