sudo vim /etc/apache2/httpd.conf
#LoadModule php5_module libexec/apache2/libphp5.so
前面#号去掉
<Directory />
#AllowOverride none
#Require all denied
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
</Directory>
修改成自己需要的目录
DocumentRoot "/Users/xiaobai/WebSites"
<Directory "/Users/xiaobai/WebSites">
添加Indexes
Options FollowSymLinks Multiviews Indexes
启动apache
sudo apachectl start
在/User/xiaobai/WebSites下面创建文件index.php内容如下:
<?php phpinfo(); ?>
打开浏览器测试localhost
显示php版本信息,成功!