美文网首页我爱编程
Mac 配置Apache自定义目录

Mac 配置Apache自定义目录

作者: 尤蛊 | 来源:发表于2018-03-27 11:16 被阅读0次

1.前往文件夹/etc/apache2
2.打开apache2文件夹下的httpd.conf
3.编辑文件以下文件内容并保存

找到 
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/Sites"
<Directory "/Users/username/Sites">
    Require all granted
    Options Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
找到 #LoadModule php7_module libexec/apache2/libphp7.so 去掉前面的#

⚠️username是你的用户名,Sites是你的根目录名称,要手动创建。修改这个文件需要输入计算机开机密码。
4.使用命令行sudo apachectl start启动apache
5.打开浏览输入localhost或者172.0.0.1即可访问你的文件

相关文章

网友评论

    本文标题:Mac 配置Apache自定义目录

    本文链接:https://www.haomeiwen.com/subject/ptanqftx.html