- Install MySQL on Mac OS X if you haven’t already
- Install XCode if you haven’t already
- Do either this:
- Open NetInfo Manager
- Modify /groups/wheel/users, add a new value for your login id, this will come into play later
or this:
$ niutil -appendprop / /groups/wheel users yourloginid
- Get PHP Complete Source Code from php.net – http://php.net/get/php-5.2.2.tar.gz/from/a/mirror (more current versions are out now)
- Open it up on your desktop, leaving a php-[version] folder:
$ tar xvzf /path/to/php-[version].tar.gz - Look at your phpinfo.php file (details in Enable PHP on Mac OS X 10.4.x)
- Copy the Configure Command
- Paste it into a vim buffer and strip out the ‘
- :%s/’//g
- NOTE:
/SourceCache/apache_mod_php/apache_mod_php-18.8/php/configureis not part of what we need - Remove the
--without-pearand change--with-mysql=/usrto be--with-mysql=/usr/local/mysql - Configure from my Mac OS X 10.4.9 Intel MBP Core Duo looks like this:
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking --with-apxs --with-ldap=/usr --with-kerberos=/usr --enable-cli --with-zlib-dir=/usr --enable-trans-sid --with-xml --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-dbx --enable-sockets --with-iodbc=/usr --with-curl=/usr --with-config-file-path=/etc --sysconfdir=/private/etc --with-mysql=/usr --with-mysql-sock=/var/mysql/mysql.sock --without-pear
- Configure, make, make install, and setup the rest in terminal
$ cd /usr/local/mysql/lib $ sudo ln -s . mysql $ cd ~/Desktop/php-[version]/ $ ./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking --with-apxs --with-ldap=/usr --with-kerberos=/usr --enable-cli --with-zlib-dir=/usr --enable-trans-sid --with-xml --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-dbx --enable-sockets --with-iodbc=/usr --with-curl=/usr --with-config-file-path=/etc --sysconfdir=/private/etc --with-mysql=/usr --with-mysql-sock=/var/mysql/mysql.sock --without-pear $ make $ sudo make install $ sudo cp /etc/php.ini.default /etc/php.ini $ sudo vim /etc/php.ini
- Edit the php.ini to have the include_path line match the following:
include_path = ".:/php/includes:/usr/lib/php"
- Edit httpd.conf to use PHP5, not PHP4 (as it does by default), basically change all instances of php4 to php5
$ sudo vim /etc/httpd/httpd.conf
- Restart apahce: $ sudo apachectl restart
- Verify PHP, MySQL, and Apache are playing nice. Create a file with the following contents and confirm you get data back, not an error. Name it something like mysqlphptest.php. If you place it directly in your document root (/Library/WebServer/Documents) you can access it by going to http://localhost/mysqlphptest.php
<?php mysql_pconnect('localhost', 'root', '') or die("Error: ".mysql_error()); mysql_select_db('mysql') or die("Error: ".mysql_error()); print_r(mysql_fetch_array(mysql_query('SELECT * FROM user LIMIT 1'))); ?>
- Get PEAR working – Enable PEAR on Mac OS X 10.4.x