Installing PHP, MySQL and phpMyAdmin on OS X 10.5 (Leopard)
Today I set about installing Joomla RC 1.5 onto my Mac Book Pro running OS X 10.5.1 (Leopard).
In order to to do this I have needed to enable PHP , Instal MySQL and phpMyAdmin before even getting as far as down loading and installing Joomla. I thought others might find the process (and Web Articles I used useful) So here goes.
Lots of blogs say that Leopards implementation is incomplete but I decided to stick with it until I find I need something it doesn’t have. Before I could use Leopards PHP I needed to enable it. I did this using a text editor to edit /etc/apache2/httpd.conf to make sure the LoadModule php5_module libexec/apache2/libphp5.so line was not commented out. (Its commented out if it begins with a # , and can be uncommented by simply removing the #).
Next I needed to make sure apache was running by going to System Preferencesand choosing Sharing and making sure Web Sharing was active by ticking the check box.
I then created a simple php text page and saved it as Test.php in the ~/Sites folder under my home directory. I could then test PHP was operational by using a browser and navigating to http://127.0.0.1/~Scotty/Test.php (Scotty is my user name on my Mac Book Pro)
For more info on setting up a PHP website on an OS X box try Working with PHP 5 in Mac OS X 10.5 (Leopard) - Professional PHP
So with PHP up running next I need to install MySQL.
At the time of writing the MySQL web site had a dmg image for Tiger but apparently it has a few problems on Leopard. After doing a bit of reading it seemed the best way of getting MySQL onto a Leopard machine was to download the source , compile and install it. Now I’m no command line geek so I was definitely looking for help here and fortunately found it in an article called Installing MySQL on Mac OS X at Hivelogic. This article takes you through the entire process including downloading the source from the command line. The whole process I have to say went pretty smoothly.
I then set up a user called Scotty in mysql by using the terminal to go into mysql
mysql -uroot
and typing the following
GRANT ALL PRIVILEGES ON *.* TO Scotty@localhost IDENTIFIED BY 'myPassword'
With MySQL installed and hopefully configured enough for PHP and phpMyAdmin it was time to have a go at installing phpMyAdmin where I discovered a problem with PHP and MySQL on Leopard. This problem boils down to the location of the location of the mysql.sock file. I did a bit of googling and read a number of ways to deal with this but I tried the one detailed in Working with PHP 5 in Mac OS X 10.5 (Leopard) - Professional PHP
The problem seemed to be that the default location for the mysql.sock file has now moved to the /var/mysql directory. PHP will look for it there. Unfortunately, the default location where it is placed by MySQL is still the old location. I fixed this by creating a my.cnf configuration file in the /etc directory and saved the file with the following contents
[client]
socket = /var/mysql/mysql.sock
[mysqld]
socket = /var/mysql/mysql.sock
In the terminal window I then created the folder and set its access rights using
sudo mkdir /var/mysql
sudo chown _mysql /var/mysql
So with done I could get back to installing phpMyAdmin. First I downloaded phpMyAdmin from here Once downloaded I unpacked the file to the ~/Sites folder under my home folder and renamed the extracted directory from phpMyAdmin-2.11.3-english to phpMyAdmin.
Next I edited the config.sample.inc.php file in the phpAdmin directory and changed the line $cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ so that it contained a value $cfg['blowfish_secret'] = 'ba17c1ec07d65003'; /. I then saved the file as config.inc.php
Then in Safari I navigated to http://127.0.0.1/~Scotty/phpMyAdmin/ which presented me with a log in screen in which I set the user as Scotty and used the password I set when I granted all privileges to Scotty@localhost earlier when setting up MySQL and voila , a working phpMyAdmin.
So at last I could actually get round to installing Joomla.
February 2nd, 2008 at 5:40 pm
Thanks for sharing
February 2nd, 2008 at 11:50 pm
Great guide, thanks. I also tried out MAMP but found it was too limited unless you went for the pro version. I decided instead to do it manually and save a few bucks and learn a thing or two about how it all works and it has been very educational. It has also meant being able to have complete control over what I install (such as ImageMagick etc). Thanks again.
February 20th, 2008 at 4:38 am
In the GRANT ALL PRIVILEGES command, I think there must be a semicolon at the end…
March 2nd, 2008 at 12:36 am
Thanks heaps for this, i just got my mac yesterday, out everything mentioned here, can someone please guide me and tell me how I can find the “etc” folder? thanks
March 4th, 2008 at 1:41 pm
When in the Finder go to Go, then Go to Folder.
April 9th, 2008 at 4:38 am
It is simply amazing how difficult, obscure, and arcane this process is. I have been googling, installing, reinstalling mysql, etc, etc. But your solution worked for Leopard 10.5.2 on my MacBook Pro.
Bravo
My best regards to a most tenacious fellow
mickster