配置php环境
进入/etc/apache2/httpd.conf 目录
找到 LoadModule php5,看自己的配置,版本无所谓,去掉前面的注释 ‘#’ (我已经去掉过了)
打开记事本,写如下代码并保存为index.php文件放在/Library/WebServer/Documents下
代码:<?php phpinfo(); ?>
重启apache sudo apachectl restart 有php的info则配置成功
更改apache根目录
进入/etc/apache2/httpd.conf 目录搜索关键词 DocumentRoot 找到如下代码
DocumentRoot “/Library/WebServer/Documents” <Directory “/Library/WebServer/Documents”>
把 “ ”内的内容改为要更改的目录可能会出现403 Forbidden错误搜索关键词 User
User _www Group _www
因为User和Group默认都是_www,但是当前用户并不一定是_www 设置User为当前电脑的username即可
搞定!