Install PHP5 on Mac OS X 10.4.x

  1. Install MySQL on Mac OS X if you haven’t already
  2. Install XCode if you haven’t already
  3. 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
  4. 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)
  5. Open it up on your desktop, leaving a php-[version] folder:
    $ tar xvzf /path/to/php-[version].tar.gz
  6. Look at your phpinfo.php file (details in Enable PHP on Mac OS X 10.4.x)
  7. Copy the Configure Command
  8. Paste it into a vim buffer and strip out the ‘
    • :%s/’//g
    • NOTE: /SourceCache/apache_mod_php/apache_mod_php-18.8/php/configure is not part of what we need
    • Remove the --without-pear and change --with-mysql=/usr to 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
  9. 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
  10. Edit the php.ini to have the include_path line match the following:
    include_path = ".:/php/includes:/usr/lib/php"
  11. 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
  12. Restart apahce: $ sudo apachectl restart
  13. 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')));
    ?>
  14. Get PEAR working – Enable PEAR on Mac OS X 10.4.x

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">