• Mac下配置apache


    一、前言

        今天遇到问题,怎么配置apache在Mac上,原来Mac自带apache,只需要自己开启配置一下就行了。

    二、步骤:

        1、修改apache的http_conf文件

            打开finder前往/private/etc/apache2,在这个文件加下有一个http.conf用文本编辑器打开。

            修改第一处:查找php。得到如下结果

            

        #LoadModule php5_module libexec/apache2/libphp5.so
    

      

                去掉前面的#号。

            修改第二处:查找documentRoot。会找到类似的语句

    #
    
    # DocumentRoot: The directory out of which you will serve your
    
    # documents. By default, all requests are taken from this directory, but
    
    # symbolic links and aliases may be used to point to other locations.
    
    #
    
    DocumentRoot "/Users/admin/Sites"
    
    <Directory "/Users/admin/Sites">
    
        #
    
        # 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
    

      

     

    在DocumentRoot “”引号中填入自己的路径。我的是在Users/admin/Sites,同时把紧挨着的Directory的“”引号后面也修改为自己的路径。

            修改第三处:查找:directory.会找到类似的语句

    #
    
    # "/Library/WebServer/CGI-Executables" should be changed to whatever your ScriptAliased
    
    # CGI directory exists, if you have that configured.
    
    #
    
    <Directory "/Library/WebServer/CGI-Executables">
    
        AllowOverride None
    
        Options None
    
        Require all granted
    
    </Directory>
    
     
    
    <IfModule mime_module>
    
        #
    
        # TypesConfig points to the file containing the list of mappings from
    
        # filename extension 
    

      

     

    将<Directory></Directory>中的内容修改为我上面的。

        然后保存。

        第二步:重启apache

            下边是用到的命令

          

      停止服务:sudo /usr/sbin/apachectl stop
    
                  开启服务:sudo /usr/sbin/apachectl start
    
                  重启服务:sudo /usr/sbin/apachectl restart
    

      

     

    然后在你刚在指定的文件夹下新建一个php文件测试即可。(我的在/Users/admin/Sites

    亲,成功了么?成功了请回复一下。不成功再修改,个人亲测可以。

  • 相关阅读:
    淘宝镜像安装方法
    vue项目 title处的小图标
    vue生成环境 访问路径配置
    element ui icon不展示
    vue 使用element-ui实现table表单列展示与隐藏
    通过id获取元素控制滚动位置回到顶部
    复杂传值
    vue 中el-card点击事件失效解决
    滚动条隐藏 兼容
    【javascript/PHP】当一个JavaScripter初次进入PHP的世界,他将看到这样的风景
  • 原文地址:https://www.cnblogs.com/zhanggui/p/4458134.html
Copyright © 2020-2023  润新知