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

親,成功了么?成功了請回復一下。不成功再修改,個人親測可以。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM