Install Apache/PHP/MySQL on Snow Leopard

Apache

Start Apache

sudo apachectl start

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

PHP

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

LoadModule php5_module        libexec/apache2/libphp5.so

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 (http://php.net/manual/en/timezones.php)

date.timezone =America/Vancouver

Restart Apache

sudo apachectl restart

MySQL

  • 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:
/usr/local/mysql/bin/mysql

Fix mysql.sock location in php.ini

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

Restart Apache

sudo apachectl restart

Extra

Activate PHP short tags

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

short_open_tag = Off

to

short_open_tag = On

Restart Apache

sudo apachectl restart

Reference

 

Feedback

Works great! Thanks.
fieg
Sep 21, 2009
#1
Thank you very much!
Dae
Sep 21, 2009
#2
Very simple, worked perfectly, thanks! One point, you can restart apache with just one command: sudo apachectl restart
Nick
Sep 22, 2009
#3
Thank you Nick, that's fixed :)
Jérôme Jaglale
Sep 22, 2009
#4
Thank you very much! Great tutorial.
Vik
Sep 30, 2009
#5
Awesome! Thanks for this extremely clear tutorial.
Boone
Sep 30, 2009
#6
Fantastic job! Easiest install tutorial seen yet, perfectly clear and concise!
zb
Oct 5, 2009
#7
Nice. Thanks!
Chris
Oct 7, 2009
#8
This is excellent! Thank you.
Tricia
Oct 10, 2009
#9
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.
ricbax
Oct 13, 2009
#10
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
#11
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
Luc
Oct 13, 2009
#12
Good Good Good Good Good Good !!! thx
Charles
Oct 16, 2009
#13
Thanks! This was very helpful.
Jonah
Oct 19, 2009
#14
Thanks, Works great!
Johan
Oct 20, 2009
#15
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: http://www.swoon.net/site/software.html
Johan
Oct 20, 2009
#16
This is NOT INSTALLING ! This is ENABLING... Thanks for the misleading title.
Grb0
Oct 23, 2009
#17
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 (mntoledo@gmail.com)
Oct 23, 2009
#18
Trying to open httpd.conf file to uncomment the php line and having trouble as it is a root file? This tutorial may help.. http://www.anujgakhar.com/2009/01/19/how-to-edit-httpdconf-on-macos/
Teej
Oct 24, 2009
#19
Great! Worked like a dream!
Samuel
Nov 5, 2009
#20
Thanks!!...i was having problems installing mysql. all got resolved
Konix
Nov 5, 2009
#21
thanks for being so informative! helps a lot.. also the way it's written.. So pleasant to follow! Big thanks!
Ed
Nov 7, 2009
#22
perfect. Thanks.

Nov 9, 2009
#23
Worked perfectly. Thanks
David
Nov 11, 2009
#24
straight to the point, really good
decarola
Nov 15, 2009
#25
Thanks a lot
Vasily
Nov 15, 2009
#26
Simple steps. Great job. Thanks a lot
Saud
Nov 17, 2009
#27
thanks a gig!
otsy
Nov 18, 2009
#28
This worked great, until I enabled short tags in my ini and then the date.timezone broke itself. anyone else having this issue?
morgan
Nov 20, 2009
#29
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.
Ted
Dec 2, 2009
#30
You are a master!!!! Thanks!!!
Alex
Dec 6, 2009
#31
Very well written and concise. Much appreciated :]
Jeff
Dec 7, 2009
#32
God bless You! Grazie mille.
Francesco
Dec 14, 2009
#33
Fantastic, simple guide. Seconding PHPMyAdmin help!!
Thanks
Dec 14, 2009
#34
My thanks as well.
Guy
Dec 16, 2009
#35
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
#36
Finally a simply & straight forward guide that works. Thanks.
e
Dec 24, 2009
#37
It's great to be able to search the web and find such clear (and correct) instructions. Thank you!
Beth
Dec 26, 2009
#38
I love you! :d
djalmaaraujo
Dec 28, 2009
#39
perfect
romeoracz
Dec 28, 2009
#40
Thank you, this was exactly what I was looking for!
samspencer.com
Dec 31, 2009
#41
Perfect !! Thank you !
jbuchanan7
Jan 4, 2010
#42
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
#43
Wow, that worked a charm! Thanks for your clear and concise tutorial!
Paul
Jan 6, 2010
#44
You are wonderful!! I can't thank you enough for providing this clear, concise tutorial. Thank you, thank you.
Jane
Jan 20, 2010
#45
Thanks! All working nicely!
Gunther
Jan 27, 2010
#46
VERY Much appreciated - worked perfectly - thank you!
Jono
Jan 27, 2010
#47
Ditto! Gracias!
Julia
Jan 28, 2010
#48
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
#49
This was a great tutorial. Restores my faith in humankind!
Tommy
Jan 31, 2010
#50
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
#51
Superb! Just what is needed, with no fluff. Thank you!
Chuck McKinnon
Feb 10, 2010
#52
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 "http://127.0.0.1" 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 127.0.0.1)
SAMM
Feb 11, 2010
#53
This is a perfect walk-through for someone who just wants to get this stuff working so they can move on with development. Thanks!
Simeon
Feb 11, 2010
#54
where and how do I install phpmyadmin? and anything I want to view needs to be put into the sites folder correct?
ScottNYC
Feb 12, 2010
#55
Hi, excellent guide! Thank you very much
NatMil
Feb 16, 2010
#56
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.
Imre
Feb 19, 2010
#57
Hi I have a corrupted installation of apache on snow leopard.
Anyone knows how to reinstall?
Please help
kappu
Feb 19, 2010
#58
Dude, you need a donation button.

Thanks!
Tom
Feb 20, 2010
#59
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
#60
Ummm...I'm a jackass...you did put a note there about the short tags...nevermind..

p.s. Great info here..thanks very much!
Some Guy
Feb 20, 2010
#61
Very nice - perfect instructions got me set up quickly. Thanks much!
Ray Wenderlich
Mar 1, 2010
#62
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?
BluemantisNY
Mar 2, 2010
#63
Simple et précis, bravo.
A l'essentiel tu nous à conduis ....
Merci
gderenge
Mar 12, 2010
#64
Loved this! Wish I had found it earlier!!
Girton
Mar 12, 2010
#65
use
sudo apachectl graceful
not
sudo apachectl restart
Voodoo
Mar 13, 2010
#66
Thanks for the tutorial.
baenre
Mar 15, 2010
#67
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 config.inc.php 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
#68
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?
Ben
Mar 20, 2010
#69
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/Terminal.app
In Terminal, type "open /etc" (without quotes) and you have it.
Vang Le
Mar 23, 2010
#70
Useful info. Beautiful blog design. Good work.
Reiser
Apr 2, 2010
#71
WAHOO!! That was so helpful. Thanks for taking the time to publish this. Perfect for those of us just getting started.
Tyr
Apr 5, 2010
#72
Thank you for a very clear tutorial.
Niels Bom
Apr 6, 2010
#73
Very well written tutorial, thank you
Jhimac
Apr 7, 2010
#74
Well written and simple. Got me exactly where i wanted to. Thanks.

Apr 10, 2010
#75
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 127.0.0.1 it returns the parsed output like it's supposed to.
Ryan Arana
Apr 10, 2010
#76
Great stuff!
Bert
Apr 12, 2010
#77
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
Asif
Apr 17, 2010
#78
Great! Quick and concise. Thank you.

Apr 18, 2010
#79
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?
Tony
Apr 21, 2010
#80
Thanks for the reference. I like your blog by the way. Is this your own custom design and program?
websitedesignby.com
Apr 22, 2010
#81
Yes, except the HTML of the articles, with "SECTION" comments in the source, generated by DokuWiki.
Jérôme Jaglale
Apr 22, 2010
#82
Great straight-to-the-point installation instructions.
Thank you.
Lior Tamir
Apr 25, 2010
#83
Perfect instructions! Many Thanks!
Lucas
Apr 26, 2010
#84
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
#85
Really really nice tutorial! Thanks
Philippe
May 5, 2010
#86
the 10.6 Mysql package is a tarball. is there an installer out there that i'm not aware of?
b_dubb
May 6, 2010
#87
Hi,
I think the install went ok, but where do I enter /usr/local/mysql/bin/mysql to test it?
Thanks,

Scott Gerling
May 9, 2010
#88
Useless.
groupadd mysql
command not found

what now?
grumpster
May 11, 2010
#89
FOUND IT, just needed to download the .dmg instead of the tarball.
grumpster
May 11, 2010
#90
Thanks a lot!
Roberto R.
May 11, 2010
#91
the 64 bit .dmg? or the 32 bit .dmg? which is best for 10.6?
b_dubb
May 13, 2010
#92
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
#93
Nice - concise. thanks
ron hamermsa
May 17, 2010
#94
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:
http://support.apple.com/kb/ht3696
fdoc
May 19, 2010
#95
Great tutorial
Lots of thanks!
Federico Carol
May 20, 2010
#96
Thanks..:-)..
Alim Bolar
May 23, 2010
#97
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
#98
Thanks! =)
Argent Ounce
May 26, 2010
#99
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
Richard
May 26, 2010
#100
Excellent! Very helpful. Thank you very much.
Ed A
May 31, 2010
#101
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.
Tommy
Jun 1, 2010
#102
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
#103
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
#104
Where do I find my.cnf using this installation method? Not appearing in /etc

Jun 9, 2010
#105
I need help. PHPMyAdmin wants a username and password though I did not specify one.
W. M.
Jun 10, 2010
#106
THANK YOU !! THAT WAS HELPFUL
Wael
Jun 10, 2010
#107
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!
VASUKi
Jun 11, 2010
#108
Parabens! (Congratulations!)
For this great doc.
Thanks a lot.
Thierry
Jun 17, 2010
#109
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
#110
Thanks!
Anoop J S
Jun 20, 2010
#111
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
#112
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?
John
Jun 24, 2010
#113
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/libphp5.so

...to this:

LoadModule php5_module libexec/apache2/libphp5.so #edited by John

...so 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
#114
Brill!
FADMark
Jun 25, 2010
#115
Thanks!!!

It's a great doc!!!
alexandre Takashi
Jun 28, 2010
#116
doesn't work for me :(
greg
Jun 29, 2010
#117
Thanks a lot.
Ignacio
Jul 2, 2010
#118
This was amazing, I was ready to climb mountains and slay dragons for a tutorial this clear. Cheers!
Johnny
Jul 2, 2010
#119
this was just awesome man
thanks a lot...........
it finally started php in my macbook pro
Rahul
Jul 7, 2010
#120
thanks for the tutorial. simple & straightforward. much appreciated
Martin
Jul 11, 2010
#121
Short, sweet and fully functional. Thanks!
whisperycat
Jul 13, 2010
#122
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
#123
If you already had mysql running, you can stop/start it like so:

sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
Password:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
Password:
adam
Jul 19, 2010
#124
This is the greatest thing ever. You are the bomb!
Will Tran
Jul 22, 2010
#125
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
#126
wow.. this is great...

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

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/apache2/httpd.conf

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

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


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

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?
HelpPlease
Sep 9, 2010
#147
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

/usr/local/mysql/bin/mysql

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



Am I good to go?

Thanks and thank you for making the selfless effort!!
Peter
Sep 11, 2010
#148
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?

Thanks!
Peter
Sep 11, 2010
#149
Peter: good job and yes, you're good to go. For MySQL, phpMyAdmin (http://www.phpmyadmin.net/home_page/index.php), a web interface, is the most popular tool. Good luck :)
Jérôme Jaglale
Sep 11, 2010
#150
excellent guide
kent
Sep 19, 2010
#151
I was about to macports the crap out of my fresh Snow Leopard system. Thanks for these instructions, works great!
Joe
Sep 20, 2010
#152
Awesome thanks!
Jeroen
Sep 21, 2010
#153
Back to the basic.

Thanks.
Choopong
Sep 27, 2010
#154
You're awesome, thanks a bunch!
Alex
Sep 28, 2010
#155
Thanks a lot for this tutorial. Simple and efficient.
Fabrice
Oct 7, 2010
#156
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)
Shrenster
Oct 7, 2010
#157
Nicely done. Many thanks. Fixed my php/mysql and phpMyAdmin connection issues.
mickster99
Oct 13, 2010
#158
Simple and straightforward, thanks!

Oct 13, 2010
#159
Thanks a lot.
this instruction solved a huge problem that I've been having for the past week.
Ehsan.K
Oct 17, 2010
#160
Thank you!
Steve
Oct 20, 2010
#161
Awesome mate! Thank you! Cheers!
Ricardo
Oct 21, 2010
#162
Runs like a charm, thanks a lot!
Kees
Oct 30, 2010
#163
The permissions for php.ini should be 664 NOT 666.
AJ
Oct 30, 2010
#164
Fantastic! The only guide you need.
The other guides I found on the web were like chinese :) !
Oskar Wild
Oct 31, 2010
#165
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
#166
This is one of the best tutorials i’ve ever used. Thank you very much for your help. took 2 mins to do.
Smilinmonki
Nov 2, 2010
#167
Tried: Check it's working: http://localhost/

Result:

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
#168
Concise, to the point, and most importantly, correct. Excellent guide.
tribbles
Nov 4, 2010
#169
Thank you! Thank you! Thank you!
A very thankful person
Nov 6, 2010
#170
I have been looking for instructions on how to get query logging working.

http://dev.mysql.com/doc/refman/5.1/en/query-log.html

I am using mysql-5.1.34.

I am also on Leopard 10.5
Rob
Nov 7, 2010
#171
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!
gsh
Nov 12, 2010
#172
thanks @jérôme.
big help.
sebby
Nov 13, 2010
#173
Amazing! Thank you for the perfect instruction set.
sahand
Nov 19, 2010
#174
Thanks!
Gonza
Nov 22, 2010
#175
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. ?????
Al
Nov 24, 2010
#176
Thank you.
yi3artist
Nov 30, 2010
#177
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: http://blog.deversus.com/2010/11/mac-os-1065-apachectl-usrsbinapachectl-line-82-ulimit-open-files-cannot-modify-limit-invalid-argument/

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

Markus
Dec 4, 2010
#181
Clear steps that work, presented in a perfectly readable format. The perfect tutorial, thanks!
Noel Rivas
Dec 11, 2010
#182
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
#183
Thank you so much. It's very simple.
comeddy
Dec 17, 2010
#184
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: http://hivelogic.com/articles/installing-mysql-on-mac-os-x. But it is not necessary to compile mysql-64bit via the terminal.
Hans
Dec 26, 2010
#185
Thank you very much!!! Excellent tutorial!!! Happy Holidays!!!
Zhannett
Dec 26, 2010
#186
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!!
Phil
Dec 28, 2010
#187
If the mysql server will not start, see this: http://forums.mysql.com/read.php?11,399397,399606#msg-399606
Terry Poland
Dec 29, 2010
#188
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....
Chris
Jan 7, 2011
#189
Excellent set of instructions... Could not get simpler than that.
Thanks!
Neha Bansal
Jan 17, 2011
#190
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
#191
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
#192
Just threw MAMP out the window and used your tutorial. Great, thanks a lot!
frenkie
Jan 27, 2011
#193
Very helpfull,

thanks a lot!
David
Feb 2, 2011
#194
wow !!! it works thanks.
EdMo
Feb 12, 2011
#195
clean and simple. thanks bro.
mx
Feb 14, 2011
#196
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
#197
oops, my fault!
I didn't change the .html extension into .php!!!
Marco Ottolini
Feb 23, 2011
#198
Great walkthrough around a notorious minefield. Thanks.
rado
Feb 27, 2011
#199
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`"

to

ULIMIT_MAX_FILES=""

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.

http://excid3.com/blog/2010/12/usrsbinapachectl-line-82-ulimit-open-files-cannot-modify-limit-invalid-argument/
Matt
Mar 1, 2011
#200
thanks, thanks, thanks :) now my phpmyadmin (finaly) works!
Angela
Mar 3, 2011
#201
Simple and quick, thanks!
Matt Witherow
Mar 5, 2011
#202
excellentttttttt!!!!!
Matia
Mar 9, 2011
#203
Great!!!
DarkAlex
Mar 11, 2011
#204
Thank you for a very clear tutorial.

Mar 14, 2011
#205
finally... easy to use, straightforward directions, thank you!!!
watertower
Mar 14, 2011
#206
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: http://www.joelgerard.com/2011/03/18/mysql-access-denied-on-osx-10-6-6/
Joel
Mar 18, 2011
#207
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.
Kiernan
Mar 30, 2011
#208
Thank you! The tutorial is clear.
Simon
Apr 3, 2011
#209
Thank YOu !
Yakuza
Apr 9, 2011
#210
Awesome! Worked every step of the way:)
Jamahl
Apr 14, 2011
#211
Thanks a lot!
Wilson
Apr 15, 2011
#212
Great Tuto thx.
EadilE
Apr 17, 2011
#213
From Russia with love! It's realy nice!!! Simple for us (for your it's hard work) and perfect!!!
tigos2
Apr 25, 2011
#214
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 http://127.0.0.1 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.
Wayne
Apr 27, 2011
#215
Thank you! I don't know why i ever installed MAMP.
Martijn Lafeber
May 4, 2011
#216
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.
CoiSA
May 6, 2011
#217
mysql.sock file not appear anywhere, and without it I can't configure MySQL. Any suggestion?

Thanks
Marc Gibert
May 9, 2011
#218
thank you very much! very good information very easy to follow. Everything works great!
Vincent
May 11, 2011
#219
Thank you for the great tutorial, works flawless
Nick
May 13, 2011
#220
Thanks a lot.
Kenol
May 15, 2011
#221
great
david raudales
May 27, 2011
#222
Nice Tut
Dave
Jun 1, 2011
#223
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
#224
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 .... ......
<?php
$basedatos="clientes";
$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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&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;
&lt;/head&gt;
&lt;body&gt;
&lt;?php
if ($crear) {
$mensaje = "<h2>La base de datos ha sido creada exitasamente!!!</h2>";
echo ($mensaje);
}
?&gt;
&lt;/body&gt;
&lt;/html&gt;

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

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&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;
&lt;/head&gt;

&lt;body&gt;
&lt;?php
if($conexion){
echo " la conexion se ha realizado con exito!!!!";
}

?&gt;
&lt;/body&gt;
&lt;/html&gt;

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

Jul 9, 2011
#234
Great - nice and clear
David
Jul 16, 2011
#235
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
kukukuan
Jul 19, 2011
#236
It's also OK for Lion (installed from AppStore, on SL).
Only, I had to recreate php.ini with same settings than SL

Cool!
uocram
Jul 20, 2011
#237
I love concise and clean. You rock!
Daniel Lewis
Jul 20, 2011
#238
Thank you! This was a big time saver.
Kapil Karekar
Jul 21, 2011
#239
Thank you, very helpful!
Chris Chinchilla
Jul 28, 2011
#240
awesome!
salman munir
Jul 29, 2011
#241
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.
http://excid3.com/blog/usrsbinapachectl-line-82-ulimit-open-files-cannot-modify-limit-invalid-argument/

Thanks again
Martin
Aug 1, 2011
#242
Thank you for writing this! Your instructions for PHP were much easier than most other tutorials' and worked quite well.
Jeffrey Jacobson, http://publicvr.org
Aug 16, 2011
#243
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 :)
mahesh
Aug 21, 2011
#244
I don't know who you are but I love you for this! Thank you Thank you Thank you!! You made my day!
amherst
Aug 23, 2011
#245
Thanks, great tutorial, simple yet complete
rafa
Aug 26, 2011
#246
Hello Jérôme Jaglale,
Any update for Mac OS X Lion.
Piyush
Aug 29, 2011
#247
great! thanks!
Luis
Aug 31, 2011
#248
Thank you very much.
Saeid
Aug 31, 2011
#249
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
#250
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
Nandini
Sep 8, 2011
#251
Thanks..
rosh CHERIAN
Sep 20, 2011
#252
Thank's from Spain (Europe)
Enrique Castro
Sep 21, 2011
#253
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?
Clam
Oct 1, 2011
#254
Awesome!
Now I can officially get rid of MAMP... I'll miss it though

Oct 4, 2011
#255
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.
Jon
Oct 8, 2011
#256
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.
Arthur
Oct 12, 2011
#257
Cheers all. Works on OS X Lion as well. Just need to install the 64-bit DMG MySQL package from http://dev.mysql.com/downloads/mysql.
Mark in South Carolina
Oct 19, 2011
#258
Perfect !!
Greats :)
thanks Man !
www.gladsonreis.com
Oct 20, 2011
#259
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
Mbit
Oct 25, 2011
#260
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

http://brunitto.wordpress.com

Good job!
Bruno
Nov 4, 2011
#261
I LOVE YOU. IT'S AS SIMPLE AS THAT. DO YOU WANT MONEY? MY SOUL, MAYBE? IT IS ALL YOURS. YOU, SIR, HAVE SAVED ME.
Walter
Nov 12, 2011
#262
Wow, this is great and easy to follow. Heaps of Thanks.
Siti G
Nov 20, 2011
#263
This is the best tutorial for installing/configuring PHP+mysql+Apache ever made.
Vale
Nov 23, 2011
#264
I did not know that Apache and PHP is available in Macbook my default.
Satya Prakash
Nov 29, 2011
#265
Thanks a lot. Very useful for a green hand like me.
Tony Huang
Nov 29, 2011
#266
Very simple and clear. Thank you!!!
Matt
Dec 3, 2011
#267
"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/libphp5.so
/usr/libexec/apache2/libphp5.so: Mach-O universal binary with 3 architectures
/usr/libexec/apache2/libphp5.so (for architecture x86_64): Mach-O 64-bit bundle x86_64
/usr/libexec/apache2/libphp5.so (for architecture i386): Mach-O bundle i386
/usr/libexec/apache2/libphp5.so (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
#268
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
#269
Great resource! Thank you! Worked like a charm!
Bill at University of South Carolina
Dec 8, 2011
#270
oops sorry didn't realize this is worldwide. Look here for your timezone:
http://www.timezoneconverter.com/cgi-bin/findzone/findzone.tzc
Allan Bonadio
Dec 8, 2011
#271
By following your instructions my installation went flawlessly. Thanks for putting this out there.
Geoff in San Diego
Dec 10, 2011
#272
Works fine! Thank you, save me a lot of work.

Dec 12, 2011
#273
Thank you very much.
vpn
Dec 28, 2011
#274
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
#275
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 CarInsuranceKey.com
Mark
Feb 4, 2012
#276
Dear Jerome excellent tutorial. I really enjoyed using the step by step installations. Thanks once more
Sam
Feb 24, 2012
#277
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 :)
Tharindu
Mar 19, 2012
#278
Thank you very much!! Your cleared my error!!
JKim
Apr 12, 2012
#279
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:
http://lifehacker.com/188892/show-hidden-files-in-finder
Marek
Apr 17, 2012
#280
Thank you very much. This worked like a charm
MS
Apr 17, 2012
#281
Funcionando perfeitamente! Obrigado!
Daniel Mota
Apr 26, 2012
#282
Perfect.....simple and straight to the point....you are a life saver.....thanks
ABD
May 4, 2012
#283
it's working so fine, thank you.
deak
May 19, 2012
#284
Thank you.

Please update to indicate that either it also applies to Lion or list the changes for Lion.
Nello Lucchesi
Jun 25, 2012
#285
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?
Jim
Aug 14, 2012
#286
Worked perfectly! Thanks a lot.
Alex
Aug 21, 2012
#287
The best short tutorial on the subject ever.
Lanny
Oct 7, 2012
#288
Great, easy and works. Awesome tutorial.
Justin Mc
Nov 18, 2012
#289
It's a incredible tutorial. Thanks!
Arthur Freitas
Jan 6, 2013
#290
Congratulations.
Very well explained.
Thank you
Alain Sartre
Jul 14, 2013
#291
Gracias / Merci / Thanks
Pablo
Sep 10, 2013
#292