Thanks to all who replied. I finally worked out a schema that worked! Here it is in the order I did it:
Activate PHP
Use a text editor that will find hidden files (like TextWrangler)
Navigate to /etc/apache2/httpd.conf
Find and uncomment (take away the #) the line: #LoadModule php5_module libexec/apache2/libphp5.so
Go to /etc/php.ini.default
Open and save a copy in the /etc directory as php.ini
Open php.ini
Find ;date.timezone =
Uncomment (take away the 😉 and enter your time zone – such as America/New_York (find time zones at
http://php.net/manual/en/timezones.php)
Find:
pdo
mysql.defaultsocket= /var/mysql/mysql.sock
mysql.default_socket = /var/mysql/mysql.sock
mysqli.default_socket = /var/mysql/mysql.sock
And change to:
pdo
mysql.defaultsocket=/tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
Go to System Preferences and turn on Web Sharing (if it is already on, turn it off and then on again)
Make a note of the path to your personal website (it will be something like http"//macintosh.home/~yourname/)
To test whether PHP is working make a simple PHP file with this single function:
phpinfo()
Save it as, say, phpinfo.php in your Home Directory/Sites. Then open it in your browser (something like
http://macintosh.home/~yourname/phpinfo.php). This should come up with the PHP configuration of your PHP. If it comes up with the code instead, then PHP is not working.
MySQL
Download MySQL, Community Edition for Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive. If you have an older 32-bit machine, use the 32-bit download.
Open the disk image. Install (in order) mysql-5.5.8-osx10.6-x86_64.pkg, MySQLStartupItem.pkg, MySQL.prefPane. MySQL won't start at the moment.
Open Terminal
Type:
sudo chown -R root:wheel /Library/StartupItems/MySQLCOM
At this point probably best to do a restart.
Open Terminal
Type:
cd /usr/local/mysql to navigate to the mysql interface.
Type: sudo echo
You will be asked for your computer admin password
Then type:
sudo bin/mysqld_safe &
Then type:
bin/mysqladmin -u root password 'xxxxxxxx' to enter a root password for the MySQL database (replace xxxxxx with your chosen password. This should probably be different from your computer password. Don't forget the single quotes). Logout of Terminal.
Then look at System Preferences. Under "Other", click the MySQL button. It should say "The MySQL Server Instance is running". If you want MySQL to start on StartUp, check the box "Automatically Start MySQL Server on Startup"
phpMyAdmin
Download a suitable version of phpMyAdmin (I used phpMyAdmin-3.3.8.1-english.zip).
Move the entire folder to Home/Sites. Rename the folder something a bit more user-friendly (I renamed mine to PMA).
I used the Setup facility to produce config.inc. You can also hand code the config file from the sample file supplied.
First make a new folder in the PMA directory called config. Set the permissions for this folder (Apple-I) to Read and Write for everyone.
In your browser enter something like http"//macintosh.home/~yourname/PMA/setup
Click New Server. I used the following settings:
Server hostname: localhost
Server socket: socket
PHP extension: mysql
Authentication type: cookie
User for config auth: root
Password for config auth: The password you set for user "root"
Leave all the others blank.
Hit the Save button. If it can't save it is probably because you haven't set permissions correctly for the config folder.
You should now see your server #1, Name:localhost, Authentication type:cookie, DSN: mysql://
Under Configuration File you should see:
Default language: English (or the language you chose originally)
Default server: localhost[1]
End of Line: select Unix/Linux (\n)
Hit Download. This should download config.inc to your config folder.
Now go to the PMA folder (in Finder). Move config.inc out of the config folder into the main PMA foder. Throw away the config folder.
In your browser enter something like http"//macintosh.home/~yourname/PMA
You should get a screen asking for Username (root) and Password (the one you set). This will then go to the phpMyAdmin page where you will see the MySQL databases. Don't mess with the three MySQL databases. Don't use the database "test" because this is available to everyone. Instead use the "Create a new database" facility to make a new database and tables. Or use the SQL facility to do the same thing. You can set passwords and priveleges etc. for new databases.