Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: How to enable PHP and MySQL in 10.5 UNIX
Getting a working an Apache, MySQL, and PHP environment running in Leopard Client is quite easy. Included with OSX 10.5 are Apache2 and PHP 5.2.4, although PHP is disabled by default. So let's start by enabling PHP.
  1. Open Terminal and navigate to the apache2 directory by typing cd /etc/apache2
  2. Using your text editor of choice, open httpd.conf; in this case, we'll use pico. We must use sudo, however, as root is the owner of httpd.conf: sudo pico httpd.conf
  3. Press Control-W and search for php; uncomment the line that loads the php module by deleting the # at the front, leaving this: LoadModule php5_module
  4. Save the changes by pressing Control-X, then press Y, then press Enter.
Get MySQL Ready

Apple was kind enough to compile php with support for MySQL, so we simply need to download the proper Tiger install package for your Mac. Run the package installer, and follow the onscreen instructions to install mysql. Cool! Done, right? Not quite, we must tell php the proper location of the mysql socket. Open up Terminal again, and navigate to the php.ini.default file by typing cd /etc.

In its current state, php.ini.default does nothing; php launches with its default values. In order for php to read the ini file, it must be renamed to php.ini. We will do a copy to retain the default file, just in case:
sudo cp php.ini.default php.ini
Open the newly-created php.ini file in pico by typing sudo pico php.ini. Press Control-W and search for mysql.default_socket, and make it look like this:
mysql.default_socket = /tmp/mysql.sock
Save the changes by pressing hen pressing Control-X, then press Y, then press Enter.

Now simply navigate to the Sharing pane of System Preferences, and either start web sharing or stop and restart web sharing. You now have fully functioning PHP and MySQL in Apache2. Further configuration of MySQL is beyond the scope of this tutorial.

[robg adds: This didn't quite work on my (clean) 10.5 install. Instead, I had to follow the steps in this tutorial -- in particular, the part about creating /var/mysql (setting it to 777 perms), then editing the php.ini file to point to that directory. Once I did that, mysql started and ran as expected.]
    •    
  • Currently 3.29 / 5
  You rated: 2 / 5 (7 votes cast)
 
[98,313 views]  

10.5: How to enable PHP and MySQL in 10.5 | 3 comments | Create New Account
Click here to return to the '10.5: How to enable PHP and MySQL in 10.5' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: How to enable PHP and MySQL in 10.5
Authored by: skribble on Nov 12, '07 03:14:30PM

There are a number of ways to deal with the mysql.sock location, outlined here

The one listed in this hint is probably the best solution, but simply creating an alias also works perfectly well. The problem with editing my.conf is a number of 3rd party DB apps assume mysql.sock in in /tmp (which is the mysql default). So you'll have to deal with that (more of an inconvenience then a problem).



[ Reply to This | # ]
10.5: How to enable PHP and MySQL in 10.5
Authored by: ParadisePete on Nov 12, '07 08:39:17PM

Or you can just download MAMP. In less than five minutes you will have a fully functional Apache-MySQL-PHP stack running, with PHPMyAdmin thrown in for good measure.

Self-contained, so moving it to another computer is as simple as copying a folder.

And it's free.
And then if you really want things easy, ditch the PHP and go with Rails.




[ Reply to This | # ]
10.5: How to enable PHP and MySQL in 10.5
Authored by: iangoldby on Nov 25, '07 04:37:19AM

On my own clean install of Leopard, the method outlined in this tip worked perfectly. I did forget to restart web sharing the first time though - restarting web sharing is necessary before the edit to php.ini is recognised.



[ Reply to This | # ]