Native Web Development (apache, PHP and mySQL) on Mac OSX Leopard
If you’re a web developer and you’re on a Mac, you’re probably using MAMP or XAMPP for your all in one apache + PHP + mySQL need. But did you know that your Mac system is already a web server by default installation? Utilizing the native web server, you can save yourself from downloading stuffs you don’t need.
It is not as complicated as you think. Given that Macs are descendants of *nix system, it already has apache2 and PHP module built in, we only need to activate those two and install mySQL. Here’s how.
Activating apache web server
Piece of cake, you only need to go to System Preferences and then to the Sharing prefpane.
Inside the Sharing prefpane check the web sharing on the left hand side. Simple as that and you’re done.
You know where you have the folder Sites in your home folder? If you put anything there, it will be accessible via http://localhost/~yourusername/. Cute anot?
Activating the PHP module
You will need to type things into terminal this time. This is also a piece of cake, don’t be afraid, the Terminal is our friend :)
To run terminal you can spotlight it or go to Applications / Utilities using Finder.
Here’s what you have to do in Terminal.
- First go to
/etc/apache2/directory by typingcd /etc/apache2/<return>. If it returns an error check your input, see if you’ve typed it right. - Next on, let’s open the apache configuration file:
httpd.confas root. We do this by typingsudo nano httpd.conf. You will be prompted to enter your login password. Upon doing so, this screen will show. This is nano, Terminal’s text editor. - Now we’re going to activate the PHP5 module. If you take a look at the terminal screen, you’ll see a list of commands. We’ll do a
^Waka Where Is to find the line that saysphp5. PressCtrl+W, type inphp5<return> - Take a good look at the terminal screen, you will see this line:
#LoadModule php5_module libexec/httpd/libphp5.so. You only have to delete the # sign:
LoadModule php5_module libexec/httpd/libphp5.so - Done, now exit nano with
^Xcommand. You will be prompted to save your changes. TypeY<return> to save and exit. Don’t change the file name in process btw ;)
That’s it, we have ourselves an apache2 web server with PHP. You can check if the PHP module’s running with a simple phpinfo();
Installing mySQL
Another walk in the park. If you don’t already have it, you can download mySQL server here. You are looking for the mySQL server installer in package format, it’s the .dmg format you’re already familiar with. It’s a 60MB download, smaller than the 70+ MB XAMPP and 130+ MB MAMP ;)
Installing is simple, mount the .dmg and then install all the packages including the .prefpane. After installing all items you will be taken to the newly installed mySQL prefpane.
Done, now mySQL’s up and running. You might want to install Navicat or phpMyAdmin for the mySQL front end. Now that you have everything working, you can already start developing.
Extra: VirtualHostX to shorten your working URL
I’m not a big fan of long URLs, my working host is http://localhost/~anima/ and my phpMyAdmin URL is http://localhost/~anima/phpmyadmin/. Those are long badass URLs and I hate them, so I looked for a workaround shortening them and that’s when VirtualHostX comes to the rescue.
This way I can shorten my http://localhost/~anima/ to http://anima/ and my http://localhost/~anima/phpmyadmin/ to http://mysql/
Free version of VirtualHostX allows you to create 3 host names, that should be enough: one for the main working URL, one for mySQL and you have an extra one. Different story if you want to assign each projects of yours with a different host name. You must get a license then :)
Tyler Hall (the developer of VirtualHostX) was very kind to give me a free license of this because I tweeted something about it :)
Gotta love Macs, they have the beauty and the brains inside :) Happy developing!








nice post juragan! numpang ngelink + numpang tenar ya?
Baru aja mau install xampp. Thanks! Eh tapi cuma beda 10MB tuh jadinya :)
@Daus Haha, iyah memang, tapi the joy of doing things your way itu loh mas. dan juga, save one extra dock icon :D
this is what we call The Passion Of A Mac User hehehe
aku kok ya senengan yang instant ajah.
nice tutorial!
Thanks this was helpful. But you could ditch VirtualHostX and just edit the Apache VHosts file and your macs “hosts” file (/etc/hosts) and you can make routes like http://www.mytestsite.com go to your folder “Users/anima/Sites/testsite” i find the much more useful, so i just type in a normal domain.
Thank’s. I’m stil trying to run navicat. I can’t make it connect to localhost.
Let’s see how is my level on mac…..
@carlos oh that’s interesting, I don’t have NaviCat so I didnt try. Could you make it work?
As far I’m consern, Navicat is the best to managing MYSQL. http://www.navicat.com
Maybe you could remember the user to restart apache after editing httpd.conf
tea tree oil to treat vaginal itching Order Viagra Soft Tabs generic network card ben johnson drugs marine corps combat stress
http://rxdrugs24×7.com/product/nizoral.html