zoukankan      html  css  js  c++  java
  • 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

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

  • 相关阅读:
    还记得那种 喜欢到不行的感觉么?
    从点到面,再从面到点
    草珊瑚的常见移动网站布局
    草珊瑚的CSS基础
    表驱动编程
    如果一切需要重学,2014年应该学哪些技术?
    揭开Makefile的神秘面纱
    VIM资源
    VIM跳转技巧
    前女友究竟是一种怎样的存在?
  • 原文地址:https://www.cnblogs.com/zhanggui/p/4458134.html
Copyright © 2011-2022 走看看