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)
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。