Install Apache/PHP/MySQL on Snow Leopard


Start Apache

sudo apachectl start

Check it's working: http://localhost/


In /etc/apache2/httpd.conf, uncomment this line:

LoadModule php5_module        libexec/apache2/

Restart Apache

sudo apachectl restart

Fix a warning appearing in phpinfo()

Create /etc/php.ini and make it writable

cd /etc
sudo cp php.ini.default php.ini
sudo chmod 666 php.ini

In php.ini, find this line:

;date.timezone =

Uncomment it and insert your time zone (

date.timezone =America/Vancouver

Restart Apache

sudo apachectl restart


  • Download the MySQL package for Mac OS X.5 (32 or 64 bits depending on your machine)
  • Install everything in the package in this order: mysql, the startup item, the preference pane.
  • Start MySQL in the preference pane.
  • Test it's working:

Fix mysql.sock location in php.ini

  • In /etc/php.ini, replace the three occurences of /var/mysql/mysql.sock by /tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

Restart Apache

sudo apachectl restart


Activate PHP short tags

In /etc/php.ini, under Language Options, change

short_open_tag = Off


short_open_tag = On

Restart Apache

sudo apachectl restart




Works great! Thanks.
Sep 21, 2009
Thank you very much!
Sep 21, 2009
Very simple, worked perfectly, thanks! One point, you can restart apache with just one command: sudo apachectl restart
Sep 22, 2009
Thank you Nick, that's fixed :)
Jérôme Jaglale
Sep 22, 2009
Thank you very much! Great tutorial.
Sep 30, 2009
Awesome! Thanks for this extremely clear tutorial.
Sep 30, 2009
Fantastic job! Easiest install tutorial seen yet, perfectly clear and concise!
Oct 5, 2009
Nice. Thanks!
Oct 7, 2009
This is excellent! Thank you.
Oct 10, 2009
This is not an install! These are instructions to get the compiled and installed version on Snow Leopard started and working with PHP and MySQL. What's the difference you ask? Too much to explain here. These instructions only work on a fresh install of Snow Leopard.
Oct 13, 2009
Yes ricbax, a more accurate title would be "Start Apache, activate PHP and install MySQL on Snow Leopard" My apologies :)
Jérôme Jaglale
Oct 13, 2009
Very nice. Do you have any pointers about how to get phpmyadmin working for those of us who like a graphical mysql database manager? Thanks, -Luc
Oct 13, 2009
Good Good Good Good Good Good !!! thx
Oct 16, 2009
Thanks! This was very helpful.
Oct 19, 2009
Thanks, Works great!
Oct 20, 2009
When trying to enable the mysql prefpane I get a message that System Preferences has to restart – this because the MySQL.prefPane is a 32-bit app. Found an alternative version of the app for Snow Leopard here that solved the issue:
Oct 20, 2009
This is NOT INSTALLING ! This is ENABLING... Thanks for the misleading title.
Oct 23, 2009
Perfect! It's the first time that I can end with sucess. So, how to I creat an url like: marciotoledo.local/ and this open and website on folder? Thanks.
Marcio Toledo (
Oct 23, 2009
Trying to open httpd.conf file to uncomment the php line and having trouble as it is a root file? This tutorial may help..
Oct 24, 2009
Great! Worked like a dream!
Nov 5, 2009
Thanks!!...i was having problems installing mysql. all got resolved
Nov 5, 2009
thanks for being so informative! helps a lot.. also the way it's written.. So pleasant to follow! Big thanks!
Nov 7, 2009
perfect. Thanks.

Nov 9, 2009
Worked perfectly. Thanks
Nov 11, 2009
straight to the point, really good
Nov 15, 2009
Thanks a lot
Nov 15, 2009
Simple steps. Great job. Thanks a lot
Nov 17, 2009
thanks a gig!
Nov 18, 2009
This worked great, until I enabled short tags in my ini and then the date.timezone broke itself. anyone else having this issue?
Nov 20, 2009
I also recommend enabling short tags; on Snow Leopard, they're off by default. I was scratching my head for nearly an hour trying to get an old script to run, but it was short tags.
Dec 2, 2009
You are a master!!!! Thanks!!!
Dec 6, 2009
Very well written and concise. Much appreciated :]
Dec 7, 2009
God bless You! Grazie mille.
Dec 14, 2009
Fantastic, simple guide. Seconding PHPMyAdmin help!!
Dec 14, 2009
My thanks as well.
Dec 16, 2009
Great Tutorial. I transferred my PowerBook G4 account to a new MacBook Pro with the Apple Migration Assistant application in the Applications>Utlities folder (and of course a firewire cable, ethernet works too). All the files including the MySQL DB transferred without me doing anything except this tutorial. My MySQl folder from my old PowerBook G4 was called "mysql-5.0.37-osx10.4-powerpc". In the /usr/local/mysql-5.0.37-osx10.4-powerpc are all my Db's with the usernames and paswords. There was really nothing else but this tutorial to get me converted over. Dang this is a life saver tutorial!!!!
Long Time PHP MySQL user - Matt
Dec 19, 2009
Finally a simply & straight forward guide that works. Thanks.
Dec 24, 2009
It's great to be able to search the web and find such clear (and correct) instructions. Thank you!
Dec 26, 2009
I love you! :d
Dec 28, 2009
Dec 28, 2009
Thank you, this was exactly what I was looking for!
Dec 31, 2009
Perfect !! Thank you !
Jan 4, 2010
Easy tutorial! Thanks! Plz add a note to change short_open_tag to On if php doesn't seem to work. I took me hours to solve that issue...
Peter Parker
Jan 6, 2010
Wow, that worked a charm! Thanks for your clear and concise tutorial!
Jan 6, 2010
You are wonderful!! I can't thank you enough for providing this clear, concise tutorial. Thank you, thank you.
Jan 20, 2010
Thanks! All working nicely!
Jan 27, 2010
VERY Much appreciated - worked perfectly - thank you!
Jan 27, 2010
Ditto! Gracias!
Jan 28, 2010
Jerome, great stuff - could you please add two things for others like me, just to save them 10mins I spent fixing up afterwards?

First - it's worth putting both php.ini edits in the same block, or repeat the chmod lines etc?

Second - for those using ~/Sites/ instead of the root /Library/WebServer/Documents/ it would be worth adding the fix I found elsewhere on the web -for /etc/apache2/users/(username).conf for FollowSymlinks and Allow All?

My wordpress/php running nicely now thanks in no small part to you! Cheers.
Andrew Walker
Jan 30, 2010
This was a great tutorial. Restores my faith in humankind!
Jan 31, 2010
Thank you so much for this concise and powerful article! It simplifies things for those of us who kinda know what we need to do, but don't remember the commands. I'm officially bookmarking this one!
Tyler Bird
Feb 8, 2010
Superb! Just what is needed, with no fluff. Thank you!
Chuck McKinnon
Feb 10, 2010
Hi,great guide. Ok I know I'm OT but i'm having this issue:
I'm behind a proxy on my college network, if i turn off the wifi and type "http://MyMacName" or "http://localhost" or "" i got an error msg from firefox cause i'm offline. If i turn on airport and connect to the college network i got and error from the proxy "ERROR The requested URL could not be retrieved
". Really don't know what to do..I checked the hosts file but it seems ok (i should be correctly
Feb 11, 2010
This is a perfect walk-through for someone who just wants to get this stuff working so they can move on with development. Thanks!
Feb 11, 2010
where and how do I install phpmyadmin? and anything I want to view needs to be put into the sites folder correct?
Feb 12, 2010
Hi, excellent guide! Thank you very much
Feb 16, 2010
Thanks for the tutorial. I found out that you can recently download a snow leopard version of mysql which is probably the same as the leopard version.
Feb 19, 2010
Hi I have a corrupted installation of apache on snow leopard.
Anyone knows how to reinstall?
Please help
Feb 19, 2010
Dude, you need a donation button.

Feb 20, 2010
Quick tip : you need to set "short_open_tag = On" in /etc/php.ini if you want to use the short tag <? instead of <?php

I thought something was wrong until I edited my test.php page to use <?php
Now it works. I guess it's better to use the long php tags, but in case you don't it's good to know this little tip.
Some Guy
Feb 20, 2010
Ummm...I'm a did put a note there about the short tags...nevermind..

p.s. Great info here..thanks very much!
Some Guy
Feb 20, 2010
Very nice - perfect instructions got me set up quickly. Thanks much!
Ray Wenderlich
Mar 1, 2010
When I log in to http://localhost/ it states that the server cannot be found. Obviously there's something wrong with the Apache setup but I can't figure out where to look. Once that's up and running I should be able to get PHP and MySQL running... Anyone out there in the same boat?
Mar 2, 2010
Simple et précis, bravo.
A l'essentiel tu nous à conduis ....
Mar 12, 2010
Loved this! Wish I had found it earlier!!
Mar 12, 2010
sudo apachectl graceful
sudo apachectl restart
Mar 13, 2010
Thanks for the tutorial.
Mar 15, 2010
Thanks for this tutorial! It worked perfectly for me.

I was also having trouble getting phpMyAdmin working. I discovered that you need to update the socket for phpMyAdmin just as you did for php.ini. So edit like this:

change-- $cfg['Servers'][$i]['socket'] = '';
to-- $cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';

I think you could probably do this in the regular phpMyAdmin setup menu too. I won't try it because I've got things running and I need to get back to work!

Adrienne Adams
Mar 18, 2010
I cannot locate the /etc/... directory. Is this because I am not running Mac OS X Snow Leopard not Mac OS X Snow Leopard Server?
Mar 20, 2010
Thanks for saving my time :)
@Ben: /etc and other unix like directories don't show up by default. You can open terminal by searching spotlight for "terminal" or opening /Applications/Utilities/
In Terminal, type "open /etc" (without quotes) and you have it.
Vang Le
Mar 23, 2010
Useful info. Beautiful blog design. Good work.
Apr 2, 2010
WAHOO!! That was so helpful. Thanks for taking the time to publish this. Perfect for those of us just getting started.
Apr 5, 2010
Thank you for a very clear tutorial.
Niels Bom
Apr 6, 2010
Very well written tutorial, thank you
Apr 7, 2010
Well written and simple. Got me exactly where i wanted to. Thanks.

Apr 10, 2010
Thanks for this very clear and concise tutorial.

I'm curious if it's just me and there's some setting I can change but when I try to access php files using http://localhost it just returns the code as plain text, however if I use my local ip address, or even it returns the parsed output like it's supposed to.
Ryan Arana
Apr 10, 2010
Great stuff!
Apr 12, 2010
Thanks :)
I used just the mysql part of this tutorial, and it worked perfectly!
Now if the mysql people would just put the above short instructions in their README.txt
Apr 17, 2010
Great! Quick and concise. Thank you.

Apr 18, 2010
I get error messages in terminal , that error logs cannot be open acces denied. And the browsers loads without ever finding a page. Any ideas?
Apr 21, 2010
Thanks for the reference. I like your blog by the way. Is this your own custom design and program?
Apr 22, 2010
Yes, except the HTML of the articles, with "SECTION" comments in the source, generated by DokuWiki.
Jérôme Jaglale
Apr 22, 2010
Great straight-to-the-point installation instructions.
Thank you.
Lior Tamir
Apr 25, 2010
Perfect instructions! Many Thanks!
Apr 26, 2010
You should also add that you will need to change DirectoryIndex to include...

DirectoryIndex index.htm index.html index.php
Tom Lynch
May 4, 2010
Really really nice tutorial! Thanks
May 5, 2010
the 10.6 Mysql package is a tarball. is there an installer out there that i'm not aware of?
May 6, 2010
I think the install went ok, but where do I enter /usr/local/mysql/bin/mysql to test it?

Scott Gerling
May 9, 2010
groupadd mysql
command not found

what now?
May 11, 2010
FOUND IT, just needed to download the .dmg instead of the tarball.
May 11, 2010
Thanks a lot!
Roberto R.
May 11, 2010
the 64 bit .dmg? or the 32 bit .dmg? which is best for 10.6?
May 13, 2010
Very nice and handy, thank you.
I'll add a couple of things though:

1) add the mysql bin path to the PATH environment variable: edit (or create if it doesn't exist) the file .profile in your home directory, then add the following line:

export PATH=$PATH:/usr/local/mysql/bin

save and close. on the next terminal window you open, you should be able to enter mysql commands without specifying the full path (i.e. mysql, mysqladmin...)

2) set the password for the mysql root account. By default the mysql root account comes with no password, so it would be much safer to set one. Open the terminal and issue the following command:

sudo mysqladmin -u root password NEWPASSWORD

(or use /usr/local/mysql/bin/mysqladmin, instead of mysqladmin, if you didn't update the PATH as previously specified).
fabio cionini
May 17, 2010
Nice - concise. thanks
ron hamermsa
May 17, 2010
Excellent! Easy for anyone with a bit of command-line experience.

For B-dubb: Snow Leopard is 64-bit native, BUT, it really depends on the processor. Only Intel (but not the early ones) are 64-bit. See this Apple Doc:
May 19, 2010
Great tutorial
Lots of thanks!
Federico Carol
May 20, 2010
Alim Bolar
May 23, 2010
a much easier way to add a path in OS X:

sudo sh -c 'echo "/usr/local/mysql/bin" > /etc/paths.d/mysql'
Elliot Betancourt
May 24, 2010
Thanks! =)
Argent Ounce
May 26, 2010
Great, straight forward.
@Elliot I've been looking for that line for ages.

sudo sh -c 'echo "/usr/local/mysql/bin" > /etc/paths.d/mysql'

Exactly what I've needed. The biggest advantage over using the .profile method, it also works when calling programs from within a shell script
May 26, 2010
Excellent! Very helpful. Thank you very much.
Ed A
May 31, 2010
Brilliant! I had been trying to use entropy and it tryed to download the php files rather than open them. I uninstalled entropy, did this and it worked! Thank you.
Jun 1, 2010
Everything is working fine, just one problem: I can't access my own MySQL with PHPMyAdmin. It asks for a password and I don't know what it want's… I never specified anything. Just installed as described above.
W. M.
Jun 3, 2010
Thank you to you, God, Satan, Allah, Buddha, Ganesha and all the others out there that tried to foil/help me as I was the idiot trying to use the binaries, not the DMG-a stage five Arghh all day long. Working great - Props,

-Stu P. Didiot
Biff del Norte
Jun 8, 2010
Where do I find my.cnf using this installation method? Not appearing in /etc

Jun 9, 2010
I need help. PHPMyAdmin wants a username and password though I did not specify one.
W. M.
Jun 10, 2010
Jun 10, 2010
This is excellent! Just said "Goodbye" to MAMP. That's a heavy shit, and a ridiculously wastage of memory when PHP and Apache are given with Mac OS itself!
Jun 11, 2010
Parabens! (Congratulations!)
For this great doc.
Thanks a lot.
Jun 17, 2010
Thanks works like a charm,
Apart from that I also wanted to change my Document Root to somewhere on my desktop.

This wasn't too hard, all I had to do was sudo nano /etc/apache2/httpd.conf and replace all instances of the previous documentroot with my new path (2 instances)

But this made a Forbidden page come up when trying to access document root. No problem, wentback into httpd.conf, looked up User _www, changed it to User Elad (my account) and left the Group _www the same.

Everything works perfectly.

Ty for guide
Elad Nava
Jun 20, 2010
Anoop J S
Jun 20, 2010
I am new to the mac environment (less than 6 months) and this was the first time I was trying to host my very simple website on my server. You are a real lifesaver and I cannot thank you enough.

The real beauty of this page is in its simplicity.

May God bless you with many beautiful babies! :)
Zarrar Khan
Jun 23, 2010
Thanks for the guide. I'm having a problem though.

When I enable PHP by uncommenting that line in httpd.conf, my VirtualHosts stop working. Any ideas why?
Jun 24, 2010
Ah! Fixed it. I didn't realize the httpd.conf file couldn't have mid-line comments. I had changed this:

#LoadModule php5_module libexec/apache2/ this:

LoadModule php5_module libexec/apache2/ #edited by John that if anything went wrong I could easily find the line that I'd edited.

The tip is to open up Console and check if apache is giving you any errors (which it certainly was doing a lot of in my case).
The same John as comment #113
Jun 24, 2010
Jun 25, 2010

It's a great doc!!!
alexandre Takashi
Jun 28, 2010
doesn't work for me :(
Jun 29, 2010
Thanks a lot.
Jul 2, 2010
This was amazing, I was ready to climb mountains and slay dragons for a tutorial this clear. Cheers!
Jul 2, 2010
this was just awesome man
thanks a lot...........
it finally started php in my macbook pro
Jul 7, 2010
thanks for the tutorial. simple & straightforward. much appreciated
Jul 11, 2010
Short, sweet and fully functional. Thanks!
Jul 13, 2010
Thanks man. It was of great help. Simple and amazing stuff. Some of the comments also helped me a lot. Thanks to all those guys.
Sreedhar Manchu
Jul 19, 2010
If you already had mysql running, you can stop/start it like so:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
Jul 19, 2010
This is the greatest thing ever. You are the bomb!
Will Tran
Jul 22, 2010
Re MySQL: I'd add a recommendation (reminder?) to run /usr/local/mysql/bin/mysql_secure_installation as a final step in its installation.
Jim Miller
Jul 25, 2010
wow.. this is great...

Thanx a lot.. :)
Jul 25, 2010
Really straightforward. Nice of you to post it.
Jul 26, 2010
to open httpd.conf you could write

sudo /Applications/ /etc/apache2/httpd.conf

nice guide anyway! Thanks
Jul 27, 2010
Very Nice, Thanks!!
Jul 27, 2010
Perfect, thank you for the simplicity ;)
Jul 28, 2010
THis is the EASIEST ever!
Aug 5, 2010
thanks for this; it's the clearest, simplest explanation of this that i've found on the web. excellent
Aug 8, 2010
Totally Bad Ass - thanks man!
Aug 8, 2010
so usefull!
Aug 10, 2010
Thanks, that was easy!
Ivan Vaschenko
Aug 10, 2010
thanks! simple and useful, up to the last detail (Short tags),
milton j
Aug 12, 2010
Thanks mate - made setting up PHP and MySQL real easy!
Ben (Melbourne, Aus)
Aug 14, 2010
Fantastic, thanks. Very simple step to follow.
Aug 15, 2010
Great stuff man...Thank you very much!!!
Belgis Chial Sanchez
Aug 16, 2010
id also appreciate some help with getting phpmyadmin running, any advice?

Ankur Oberoi
Aug 20, 2010
Thank you very much for this!
Zeb DeOs
Aug 30, 2010
Sweet! I got my php.ini all configured now.
Angelo Beltran
Sep 2, 2010
You beautiful man. You saved me some headache.
Roberto Aloi
Sep 2, 2010
A really fantastic guide, bought a MacBookPro yesterday, got my Apache/PHP/Mysql working today ! Fantastic !
Josh Atkins
Sep 2, 2010
Perfect walk-trough. It helped me a lot. Thanx.
O B.
Sep 8, 2010

Hi, when I did what you said in the MAC/PHP instructions,
and go to my browser and type in this:

in the browser the results come as txt?
<?php phpinfo() ?>

like it doesn't understand the .php mime type?

if i go to a command line, and run the index.php
i get results...

any suggestions?
Sep 9, 2010
I am luddite who just bought a MacBook Pro. I wanted to teach myself PHP on the Mac and found your tutorial.

I followed each step without a problem using sudo pico php.ini from /etc (otherwise restricted from access via the desktop; vi did not work either due to same reason) to text edit opening up a text edit window to find the right line in php.ini (other too hard to find)

I am hoping you can help medetermine whether all was successful.

Where I am now:
I first click on the button "Start mySQL Server" in the System Pref popup, MySQL. Once I see that it says that "The MySQL Server Instance is running," I type at my Terminal prompt


This then gives me:
Your MySQL connection id is 540
Server version: 5.1.50 MySQL Community Server (GPL)

Am I good to go?

Thanks and thank you for making the selfless effort!!
Sep 11, 2010
sorry on above, it was of course the httpd.conf file that had the access restrictions, not php.ini, though for the latter I used the sudo pico and text Editor combo to make all changes.

As far as good to go, is all mySQL stuff to be done via the UNIX terminal? Or is there supposed to be a window?

Sep 11, 2010
Peter: good job and yes, you're good to go. For MySQL, phpMyAdmin (, a web interface, is the most popular tool. Good luck :)
Jérôme Jaglale
Sep 11, 2010
excellent guide
Sep 19, 2010
I was about to macports the crap out of my fresh Snow Leopard system. Thanks for these instructions, works great!
Sep 20, 2010
Awesome thanks!
Sep 21, 2010
Back to the basic.

Sep 27, 2010
You're awesome, thanks a bunch!
Sep 28, 2010
Thanks a lot for this tutorial. Simple and efficient.
Oct 7, 2010
This is great !! Thanks for the simplicity.

I now have Apache,Mysql,PHP,Phpmyadmin, (Drupal619 & Drush 3) all working in harmony on my Macbook Pro (OS 10.6)
Oct 7, 2010
Nicely done. Many thanks. Fixed my php/mysql and phpMyAdmin connection issues.
Oct 13, 2010
Simple and straightforward, thanks!

Oct 13, 2010
Thanks a lot.
this instruction solved a huge problem that I've been having for the past week.
Oct 17, 2010
Thank you!
Oct 20, 2010
Awesome mate! Thank you! Cheers!
Oct 21, 2010
Runs like a charm, thanks a lot!
Oct 30, 2010
The permissions for php.ini should be 664 NOT 666.
Oct 30, 2010
Fantastic! The only guide you need.
The other guides I found on the web were like chinese :) !
Oskar Wild
Oct 31, 2010
Perfect tutorial. I'm a long time Linux user and your tutorial was absolutely perfect for my use. Thank you very much!
Pierrick Le Gall
Nov 2, 2010
This is one of the best tutorials i’ve ever used. Thank you very much for your help. took 2 mins to do.
Nov 2, 2010
Tried: Check it's working: http://localhost/


Safari can’t connect to the server.
Safari can’t open the page “http://localhost/” because Safari can’t connect to the server “localhost”.

Preferences: Web Sharing: On
Jim Price
Nov 4, 2010
Concise, to the point, and most importantly, correct. Excellent guide.
Nov 4, 2010
Thank you! Thank you! Thank you!
A very thankful person
Nov 6, 2010
I have been looking for instructions on how to get query logging working.

I am using mysql-5.1.34.

I am also on Leopard 10.5
Nov 7, 2010
I'm looking on how to install apache2, i deleted the directory /etc/apache2 by mistake and screwed things up. Does anyone know how I can do this? All the links I find for installing Apache on a mac are just telling me that it comes built in!
Nov 12, 2010
thanks @jérôme.
big help.
Nov 13, 2010
Amazing! Thank you for the perfect instruction set.
Nov 19, 2010
Nov 22, 2010
I can't get this to work. I have snow leopard 10.6.5. I have web sharing on. I have php in usr/local/php5 and sql in /usr/local/mysql. I have edited the # out of the httpd.conf with sudo. And i cannot get the phpinfo() file to do anything. ?????
Nov 24, 2010
Thank you.
Nov 30, 2010
Thanks! Great post! I ran into one issue - I got this error when I tried to restart Apache: /usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument

I found a fix for this here, which worked:

Hope that helps somebody else!
Nov 30, 2010
Thanks .. to one up some else /// may you be blessed with many beautiful babies only if you want them !
Dec 2, 2010
Thanks Man!
Dec 2, 2010
Great tutorial! Thanks, saved me a lot of time!

Dec 4, 2010
Clear steps that work, presented in a perfectly readable format. The perfect tutorial, thanks!
Noel Rivas
Dec 11, 2010
Wonderful. I would give 100 points for this perfect and simple tutorial.
If Jerome were to charge for the time we would spend googling for solutions (without these steps) he would have made thousands :-)

Thanks Buddy excellent steps
Abdul Khan
Dec 14, 2010
Thank you so much. It's very simple.
Dec 17, 2010
Thanks for your Instructions. With a new iMac and OS X 10.6.5 I have had problems with the startup item («Wrong Securtiy Preferences» or something like this). I solved it with the .plist-File «com.mysql.mysqld.plist» in the folder /Library/LaunchDaemons/. Do this command too: chmod 0644 com.mysql.mysqld.plist to set correct rights. Then I deleted the StartupItem for MySQL in the Folder /Library/StartupItems/ and became happy. Some other helpful infos here: But it is not necessary to compile mysql-64bit via the terminal.
Dec 26, 2010
Thank you very much!!! Excellent tutorial!!! Happy Holidays!!!
Dec 26, 2010
Thanks - I had a problem with the Preference Pane. It would not start using mysql.server. This was overcome with just changing basedir to basedir=/usr/local/mysql in file /usr/local/mysql-5.5.8-osx10.6-x86/support-files/mysql.server and all worked instantly!!
Dec 28, 2010
If the mysql server will not start, see this:,399397,399606#msg-399606
Terry Poland
Dec 29, 2010
Thanks so much for this, it really helped. HOWEVER, I ran into some difficulty after I installed the mysql grant tables: for some reason I'm no longer able to save changes to php.ini. I keep getting an error saying that I don't have sufficient privileges... which is strange since I did just a couple days ago. Wondering if maybe this is b/c I upgraded to 10.6.6?

Any thoughts? Thanks for any help....
Jan 7, 2011
Excellent set of instructions... Could not get simpler than that.
Neha Bansal
Jan 17, 2011
This is by far, the most helpful instructions i have found on the web for PHP, MySQL connectivity. Many Thanks
Jason Meredith
Jan 22, 2011
These are very easy instructions to get started with Apache, PHP and MySQL. Definitely the way to go if you're trying to learn how to do this without the use of MAMP.
Alvin Crespo
Jan 25, 2011
Just threw MAMP out the window and used your tutorial. Great, thanks a lot!
Jan 27, 2011
Very helpfull,

thanks a lot!
Feb 2, 2011
wow !!! it works thanks.
Feb 12, 2011
clean and simple. thanks bro.
Feb 14, 2011
I'm using Mac OS X 10.6.2 on a Mac Mini. I did everything explained here, but PHP is not working. A simple <?php phpinfo(); ?> doesn't show anything and appears directly in the source code.
Any idea?
Marco Ottolini
Feb 23, 2011
oops, my fault!
I didn't change the .html extension into .php!!!
Marco Ottolini
Feb 23, 2011
Great walkthrough around a notorious minefield. Thanks.
Feb 27, 2011
Thanks for this.

i got an error when starting apache

/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument

this fix is floating around. edit the apachectl script and change

ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"



error exists as of 10.6.5-6 but maybe not worth it to add to the instructions as it could be fixed it in the future.
Mar 1, 2011
thanks, thanks, thanks :) now my phpmyadmin (finaly) works!
Mar 3, 2011
Simple and quick, thanks!
Matt Witherow
Mar 5, 2011
Mar 9, 2011
Mar 11, 2011
Thank you for a very clear tutorial.

Mar 14, 2011
finally... easy to use, straightforward directions, thank you!!!
Mar 14, 2011
Brilliant. Thanks. I had one extra problem, and got:

Access denied for user 'root'@'localhost' (using password: YES)

Turned out it was a weird loopback issue. Maybe I missed something in this article but I posted my fix here:
Mar 18, 2011
Took me about 2 hours of head scratching to find your page. And here you are. Thank you! There was no way I was going to figure out the php.ini quirks. Thank you again.
Mar 30, 2011
Thank you! The tutorial is clear.
Apr 3, 2011
Thank YOu !
Apr 9, 2011
Awesome! Worked every step of the way:)
Apr 14, 2011
Thanks a lot!
Apr 15, 2011
Great Tuto thx.
Apr 17, 2011
From Russia with love! It's realy nice!!! Simple for us (for your it's hard work) and perfect!!!
Apr 25, 2011
For me I ran into two issues.
1. I had no idea how or where to find the etc folder on a mac. I looked and could not find it. I figured it had to be hidden so a quick Google search revealed typing into finder /etc or if you know your command line cd /etc will get you in there.
2. The httpd.conf and php.ini files were read only and it told me that I did not have the permission to write to them. I even tried opening them with sudo open httpd.conf -e to no avail. What did work however is when I made my changes and saved the file to the desktop. Remember to change the extension to .conf or .ini depending on which file you are working with. I then opened the appropriate folder in finder. I closed out of the file that I had finished editing. I then did a drag and drop from the desktop to the proper directory. I told it to authorize, then replace, put in my password and was in business.

Thanks for your hard work in writing this. I now have these enabled. I saw some items above about this not being installed. What else is there? If I go to I see a webpage. As I understand it, Macintosh from Tiger and come pre-installed with PHP and all you need to know how to do is enable it.

Now, I just need to know where I can upload my pages so they will show up on the intranet.
Apr 27, 2011
Thank you! I don't know why i ever installed MAMP.
Martijn Lafeber
May 4, 2011
How can I add PostgreSQL to run with this apache?
If I want run php on console what I have to do?
I try this for many methods, but none really works.
May 6, 2011
mysql.sock file not appear anywhere, and without it I can't configure MySQL. Any suggestion?

Marc Gibert
May 9, 2011
thank you very much! very good information very easy to follow. Everything works great!
May 11, 2011
Thank you for the great tutorial, works flawless
May 13, 2011
Thanks a lot.
May 15, 2011
david raudales
May 27, 2011
Nice Tut
Jun 1, 2011
The package I just installed (mysql-5.5.13-osx10.6-x86_64) did not include anything named "the startup item, the preference pane". However, it did have ./support-files/binary-configure. I ran that and all seems to be well.
Paul Tanner
Jun 2, 2011
Hello dear friend.
I am studying programming, I'm new.
I have MAMP and mysql, work alone or with both.
But my problem is that when I create a database in mysql says no code attached to Connect .... ......
$conexion =mysql_connect("localhost","root","root") or die("No se puede realizar la conexion a la base de datos ");
$crear = mysql_create_db($basedatos,$conexion) or die ("No se puedo crear la base de datos ");
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
&lt;html &gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;CREAR LA BASE DE DATOS CLIENTES EN MYSQL&lt;/title&gt;
if ($crear) {
$mensaje = "<h2>La base de datos ha sido creada exitasamente!!!</h2>";
echo ($mensaje);

But I can connect, code attached .......

$conexion=mysql_connect("localhost","root","perro1") or die("No se puede realizar la conexion a la base de datos ");

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
&lt;html &gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;conexion entre php y MYSQL&lt;/title&gt;

echo " la conexion se ha realizado con exito!!!!";


Please could you help me, I agradecieria lot.
P.D "Greetings from Barcelona-spain
Jun 2, 2011
I encourtered every problem listed in this post. Why did I found it only now. WHYYY
Thanks very mush, gonna bookmark this.
Jun 7, 2011
Thank you for these simple and precise steps!
Jun 9, 2011
Thanks soooooo much!!! ;)
Jun 15, 2011
Thanks a los dude!
Jun 18, 2011
And it still works great! Thanks a lot!
Jun 19, 2011
MySQL 5.5.x install worked without a fresh install of Snow Leopard on my MacBook. Even the PrefPanel worked without any problem. Thanks!
Jun 26, 2011
Great guide - thanks!!
Jun 30, 2011
Awesome guide... But turning ON php shorttags sounds like a really bad idea to me ;)
Jul 7, 2011

Jul 9, 2011
Great - nice and clear
Jul 16, 2011
There is a simpler way without modifying php.ini.

make a soft link to "/var/mysql/mysql.sock" is OK.

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Jul 19, 2011
It's also OK for Lion (installed from AppStore, on SL).
Only, I had to recreate php.ini with same settings than SL

Jul 20, 2011
I love concise and clean. You rock!
Daniel Lewis
Jul 20, 2011
Thank you! This was a big time saver.
Kapil Karekar
Jul 21, 2011
Thank you, very helpful!
Chris Chinchilla
Jul 28, 2011
salman munir
Jul 29, 2011
Thanks This was very helpful.

I encountered one glitch with trying to restart apache on OS X 10.6.6.

when I tried

sudo apachectl restart

I got the error message

/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument

I found a solution to this at the following site.

Thanks again
Aug 1, 2011
Thank you for writing this! Your instructions for PHP were much easier than most other tutorials' and worked quite well.
Jeffrey Jacobson,
Aug 16, 2011
i cant edit the httpd.conf file. it comes out only in the read only mode. i am opening it with emacs on my mac. I tried to change the file permissions using chmod. it does not work either. like the system says operation not permitted. Can some one help me out with this. Thanks :)
Aug 21, 2011
I don't know who you are but I love you for this! Thank you Thank you Thank you!! You made my day!
Aug 23, 2011
Thanks, great tutorial, simple yet complete
Aug 26, 2011
Hello Jérôme Jaglale,
Any update for Mac OS X Lion.
Aug 29, 2011
great! thanks!
Aug 31, 2011
Thank you very much.
Aug 31, 2011
mahesh, try "sudo emacs httpd.conf" and enter the admin password.

I have done all this and php is not working for me. I created text file with a test php script I found, "&lt;?php phpinfo(); ?&gt;". My browser only shows it as a text file.

Does anyone know what I am doing wrong or may have missed?
Karl Jenkinson
Sep 3, 2011
Hi, I followed all the steps that you have recommended. Thanks a lot for the detailed information. However, I want to enable "root" user on mySQL which I haven't been able to do so far. I get "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)" this error every time. Can you please help me out. -Thanks in advance
Sep 8, 2011
Sep 20, 2011
Thank's from Spain (Europe)
Enrique Castro
Sep 21, 2011
Hey! Thanks for the helpful tutorial. I'm really new to this php thing, and I was wondering how to upload a php script? http://localhost/ says "It works!" and I installed MySql + the rest of the packages as well as edited the /etc/ php.ini and the httpd.conf files. But now I'm pretty lost. I tried looking up more stuff but...I'm confused. Any help?
Oct 1, 2011
Now I can officially get rid of MAMP... I'll miss it though

Oct 4, 2011
Thank you sooo much for this tutorial, I just cleaned up my mac and was reinstalling all my apps and just about forgot how to get php and mysql going again. Worked like a charm!! Many Thanks.
Oct 8, 2011
It’s really an awesome tutorial.

So, after that, how I can activate the “mail()” function on PHP? I really need this…

Thanks for this great tutorial, and waiting for the next one.
Oct 12, 2011
Cheers all. Works on OS X Lion as well. Just need to install the 64-bit DMG MySQL package from
Mark in South Carolina
Oct 19, 2011
Perfect !!
Greats :)
thanks Man !
Oct 20, 2011
is there a copy of the httpd.conf ? i made some changes in order allow .htaccess usage but no luck.. i only destroyed my conf :/ without backup
Oct 25, 2011
Nice post!

I write about Apache + PHP + MySQL installation configuration as well, it would be nice to exchange references to each other blogs, if you agree... my weblog is

Good job!
Nov 4, 2011
Nov 12, 2011
Wow, this is great and easy to follow. Heaps of Thanks.
Siti G
Nov 20, 2011
This is the best tutorial for installing/configuring PHP+mysql+Apache ever made.
Nov 23, 2011
I did not know that Apache and PHP is available in Macbook my default.
Satya Prakash
Nov 29, 2011
Thanks a lot. Very useful for a green hand like me.
Tony Huang
Nov 29, 2011
Very simple and clear. Thank you!!!
Dec 3, 2011
"Download the MySQL package for Mac OS X.5 (32 or 64 bits depending on your machine)"
might be good to give a few more hints:

all the new macs are Intel arch, and X.6 only runs on Intel arch. whereas X.5 also runs on ppc. Most binaries are fat = contain multiple archs. Use 'file' cmd to tell:

$ file `which httpd`
/usr/sbin/httpd: Mach-O universal binary with 3 architectures
/usr/sbin/httpd (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/sbin/httpd (for architecture i386): Mach-O executable i386
/usr/sbin/httpd (for architecture ppc7400): Mach-O executable ppc

httpd=apache=the top level executable. If MacOS can run the 64 bit version, it will (i think on both x.5 and x.6). because php and the apache/php adapter run in apache's process, they also must be 64 bit. (i386 and ppc7400 are 32 bit)

$ file /usr/libexec/apache2/
/usr/libexec/apache2/ Mach-O universal binary with 3 architectures
/usr/libexec/apache2/ (for architecture x86_64): Mach-O 64-bit bundle x86_64
/usr/libexec/apache2/ (for architecture i386): Mach-O bundle i386
/usr/libexec/apache2/ (for architecture ppc7400): Mach-O bundle ppc

$ file `which php`
/usr/bin/php: Mach-O universal binary with 3 architectures
/usr/bin/php (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/php (for architecture i386): Mach-O executable i386
/usr/bin/php (for architecture ppc7400): Mach-O executable ppc

and because mysql runs in PHP's address space, it should also be 64 bit.
Allan Bonadio
Dec 5, 2011
timezone for california should be America/Los_Angeles - would be handy if it listed a few TZs that developers are @.

The difference between Vancouver and Los Angeles is potentially when DST starts and ends so it might make a difference (although they seem to be the same now). Mexico's pacific time does change on different days from the US. Some places in the US don't observe DST at all, and political winds change the rules every few years. Hence the US has about 2 dozen TZs including several in Indiana. yeesh.

Allan Bonadio
Dec 5, 2011
Great resource! Thank you! Worked like a charm!
Bill at University of South Carolina
Dec 8, 2011
oops sorry didn't realize this is worldwide. Look here for your timezone:
Allan Bonadio
Dec 8, 2011
By following your instructions my installation went flawlessly. Thanks for putting this out there.
Geoff in San Diego
Dec 10, 2011
Works fine! Thank you, save me a lot of work.

Dec 12, 2011
Thank you very much.
Dec 28, 2011
This is the BEST, most concise, parsimonious set of instructions I have ever seen for XAMP! THANK YOU THANK YOU THANK YOU!!!
Daniel Robert
Jan 28, 2012
Woow! I had no idea that it's already in Mac OS X. I was looking for a pack to install to be able to enable PHP and Apache, thank you. Mark from
Feb 4, 2012
Dear Jerome excellent tutorial. I really enjoyed using the step by step installations. Thanks once more
Feb 24, 2012
Thanks lot for the clean and clear tutorial but the since the Mac OS X Lion the setting are pretty different specially the 'mysql.sock' location is changed back to '/tmp/mysql.sock' it would be great if you could update the tutorial for that change , many thanks :)
Mar 19, 2012
Thank you very much!! Your cleared my error!!
Apr 12, 2012
For half a day I couldn't find etc/apache2/. I was wondering how it is possible that I'm the only one who doesn't have it.
It turned out that I was looking at the wrong etc/ folder (Developer/usr/ect/). Maybe it was just stupid of me or maybe I'm too fresh with MacOS. The proper ect/, which is located in the main directory, was hidden, so Finder didn't show it.

Anyway, I found this info about how to show hidden filed in Finder:
Apr 17, 2012
Thank you very much. This worked like a charm
Apr 17, 2012
Funcionando perfeitamente! Obrigado!
Daniel Mota
Apr 26, 2012
Perfect.....simple and straight to the are a life saver.....thanks
May 4, 2012
it's working so fine, thank you.
May 19, 2012
Thank you.

Please update to indicate that either it also applies to Lion or list the changes for Lion.
Nello Lucchesi
Jun 25, 2012
Hi I upgraded from 10.5 server (PHP/MySql site worked perfectly there of course) to 10.6.3 (server) which broke the site, although Server Admin shows "Web" and "MySql" still functioning. I completed all of the steps in this tutorial successfully, but still no luck:

Safari says: "Safari can’t open the page “http://localhost/” because the server unexpectedly dropped the connection. This sometimes occurs when the server is busy. Wait for a few minutes, and then try again."

I read every comment above and understand that these directions work best (or only) for a clean install of 10.6. Can anyone give me bullet points on which directories need to be backed up if I want to try this again with a clean install of 10.6, in order to save my mysql data and my php site?
Aug 14, 2012
Worked perfectly! Thanks a lot.
Aug 21, 2012
The best short tutorial on the subject ever.
Oct 7, 2012
Great, easy and works. Awesome tutorial.
Justin Mc
Nov 18, 2012
It's a incredible tutorial. Thanks!
Arthur Freitas
Jan 6, 2013
Very well explained.
Thank you
Alain Sartre
Jul 14, 2013
Gracias / Merci / Thanks
Sep 10, 2013