使用默认路径
1.打开终端,开启Apache:
//开启apache: sudo apachectl start
//重启apache: sudo apachectl restart
//关闭apache: sudo apachectl stop
2.点击Finder,然后Command+Shift+G,前往Apache服务器的文件路径(/Library/WebServer/Documents)
修改默认路径
1.修改httpd.conf配置文件, 打开终端输入如下指令
sudo vim /etc/apache2/httpd.conf
2.找到文件中如下内容:
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>
修改后如下:
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>
3.打开终端重启服务
sudo apachectl restart //重启