我个人使用Macports来搭建PHP开发环境。
我猜现在这可能不是最好的解决方案,因为它需要比像Xampp这样的完整解决方案更多的配置,但它给你更多的灵活性。
Macports
安装完成后(不要忘记先安装XCode Unix工具),您可以轻松地安装软件包。例如:
sudo port install apache2
sudo port install php5 +apache2
sudo port install mysql5
你还可以轻松地添加模块:
sudo port install php5-curl
我按照以下方式设置了Apache(在stackoverflow上找到的),这样我就不必每次启动项目时都更改apache配置文件。
NameVirtualHost *:80
<VirtualHost *:80>
ServerName *.dev
VirtualDocumentRoot "/Users/les/Documents/workspace/%-2+/site/html"
</VirtualHost>
当我开始一个新项目时,我会将以下内容添加到我的/etc/hosts文件中并重新启动apache:
127.0.0.1 merchant.dev
这将有效地在 /Users/les/Documents/workspace/merchant/site/html 中运行脚本。
最后,我在我的 .bash_profile 中使用一些方便的别名。
alias ap='sudo /opt/local/apache2/bin/apachectl'
alias apconfig='mate /opt/local/apache2/conf/httpd.conf'
alias hostconfig='mate /etc/hosts'
alias dsclean='find . -name ".DS_Store" -depth -exec rm {} \;'
mate是由TextMate创建的快捷方式(一款非常有用的Mac通用文本编辑器)。
dsclean只是为了保持我们的svn存储库不受Mac垃圾的影响。