Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
I开发者_高级运维mprove this questionWhen I do PHP, I use XAMPP to set up a development environment on Windows, then upload to Linux servers, works very well.
I'm now passing on a PHP project to a person who has a Mac so he needs a local PHP dev environment. I noticed XAMPP has a version for Mac which I will recommend.
But knowing that Mac is always a bit different, has anyone used any other easy PHP environment setup tool for the Mac, or I could even imagine that Mac solves this issue more elegantly by e.g. having a web server ready to go upon first boot etc.
What is the best way to set up a PHP development environment on a Mac?
I personally use Macports to setup the PHP Development environment. My guess is this is not the best solution right now since it requires a bit more configuration then a complete solution like Xampp but it gives you a bit more flexibility.
Macports
Once you have installed this (don't forget to install the XCode unix tools first) you can easily install packages. For instance:
sudo port install apache2
sudo port install php5 +apache2
sudo port install mysql5
You can also easily add modules:
sudo port install php5-curl
I have setup Apache in the following way (Found this on stackoverflow) so I don't have to keep changing my apache conf file everytime I start a project.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName *.dev
VirtualDocumentRoot "/Users/les/Documents/workspace/%-2+/site/html"
</VirtualHost>
When starting a new project I add this to my /etc/hosts file and restart apache:
127.0.0.1 merchant.dev
Which will effectively run scripts in /Users/les/Documents/workspace/merchant/site/html
Lastly, I use some handy aliasses in my .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 is a shortcut created by textmate (really useful general purpose texteditor for mac) dsclean is just something to keep our svn repositories clean of mac litter.
If you want a easy solution I would go with MAMP. It is a simple webserver installer so most of the time you don't really have to configure anything: MAMP
If you need a userguide for installing MAMP you can find it here: Userguide
Personally, I use Zend Server Community Edition for either windows or mac. Its packaged nicely and runs in its own directories.
All you need to do is activate the web server in System Preferences > Sharing, put your files in ~/Sites and you're good to go. Nothing "different", just easier.</flamebait>
If you prefer a more standalone server, I'd recommend MAMP.
精彩评论