Php5 version 5.3.0 - How to Download and Install on Mac OS X
Tuesday the 3rd of November, 2009

    version 5.3.0

      View the most recent changes for the php5 port at: php5.darwinports.com/diff
      Scroll down toward the bottom of the page to get installation instructions for php5.
      The raw portfile for php5 5.3.0 is located here:
      http://php5.darwinports.com/dports/lang/php5/Portfile
      Find related portfiles with the unique DarwinPorts.com search feature.
      Check for any related Fink projects here: pdb.finkproject.org/pdb/package.php/php5


      The php5 Portfile 59698 2009-10-20 09:10:22Z ryandesign macports.org $

      PortSystem 1.0

      Name: php5
      conflicts php5-devel php52
      epoch 1
      Version: 5.3.0
      Revision: 3
      set major [lindex [split ${version} .] 0]
      set my_name php${major}
      dist_subdir ${my_name}
      Category: lang php www
      Maintainers: ryandesign jwa
      Homepage: http://www.php.net/
      Master Sites: php
      distname php-${version}
      use_bzip2 yes
      Platform: darwin freebsd
      use_parallel_build yes

      Description: PHP: Hypertext Preprocessor

      Long Description: PHP is a widely-used general-purpose scripting language that is especially suited for developing web sites, but can also be used for command-line scripting.

      Checksums: [suffix ${distname}] md5 846760cd655c98dfd86d6d97c3d964b0 sha1 934700941d216c453376e3bf24347041cf12c6dc rmd160 9a71b74052b0ca515f2ddf95c051b47a73d33f44

      depends_build port:pkgconfig port:autoconf213

      depends_lib path:bin/gsed:gsed port:libtool port:libxml2 port:bzip2 port:mhash port:pcre port:readline port:zlib

      # Use -p1 to accommodate the Suhosin patch
      patch.pre_args -p1
      Patch Files: patch-scripts-php-config.in.diff patch-ext-mysqlnd-mysqlnd_portability.h.diff patch-main-fopen_wrappers.c.diff patch-bind.diff

      use_autoconf yes
      autoconf.cmd ${prefix}/bin/autoconf213

      set phpinidir ${prefix}/etc/${my_name}
      set extraphpinidir ${prefix}/var/db/${my_name}

      destroot.keepdirs ${destroot}${extraphpinidir}

      configure.args --mandir=${prefix}/share/man --infodir=${prefix}/share/info --with-config-file-path=${phpinidir} --with-config-file-scan-dir=${extraphpinidir} --disable-all --enable-bcmath --enable-ctype --enable-dom --enable-fileinfo --enable-filter --enable-hash --enable-json --enable-libxml --enable-pdo --enable-phar --enable-session --enable-simplexml --enable-tokenizer --enable-xml --enable-xmlreader --enable-xmlwriter --with-bz2=${prefix} --with-mhash=${prefix} --with-pcre-regex=${prefix} --with-readline=${prefix} --with-libxml-dir=${prefix} --with-zlib=${prefix} --without-pear --disable-cgi

      # php5-mysql +mysqlnd needs mysqlnd support compiled into php
      configure.env-append PHP_MYSQLND_ENABLED=yes

      configure.universal_args-delete --disable-dependency-tracking

      platform darwin 10 {
      configure.env-append LIBS=-lresolv
      }

      platform macosx {
      configure.args-append --with-ldap=/usr
      }

      Variant: no_web conflicts apache apache2 fastcgi description {Don't include any web server support} {}

      # Build an Apache 1 module. On Mac OS X, it uses Apple's provided Apache 1 server.
      # On other platforms, the MacPorts apache port is used. Keep the options here
      # in sync with those in the relevant part of the post-destroot phase.
      Variant: apache conflicts apache2 no_web description {Add Apache 1 web server module} {
      if { ! [variant_isset macosx] } {
      depends_lib-append port:apache
      configure.args-append --with-apxs=${prefix}/sbin/apxs
      } else {
      destroot.violate_mtree yes
      configure.args-append --with-apxs=/usr/sbin/apxs
      }
      }

      # Build an Apache 2.2 module. Keep the options here in sync with those in the
      # relevant part of the post-destroot phase.
      Variant: apache2 conflicts apache no_web description {Add Apache 2.2 web server module} {
      pre-extract {
      # Checking for mod_cgi.so is a convenient way to verify apache2 is using its
      # +preforkmpm variant. (+eventmpm and +workermpm instead provide mod_cgid.so.)
      if {![file exists ${prefix}/apache2/modules/mod_cgi.so]} {
      ui_error "To use ${name} with the +apache2 variant, apache2 must be installed with the +preforkmpm variant."
      return -code error "incompatible apache2 installation"
      }
      }
      destroot.violate_mtree yes
      depends_lib-append port:apache2
      configure.args-append --with-apxs2=${prefix}/apache2/bin/apxs
      }

      # Build a FastCGI binary. Keep the options here in sync with those in the
      # relevant part of the post-destroot phase.
      Variant: fastcgi conflicts no_web description {Add FastCGI web server binary} {
      if { ![variant_isset apache] && ![variant_isset apache2] } {
      configure.args-delete --disable-cgi
      configure.args-append --enable-cgi
      }
      }

      foreach {old_variant new_port} {
      gmp gmp
      imap imap
      macports_snmp snmp
      mssql mssql
      mysql3 mysql
      mysql4 mysql
      mysql5 mysql
      mysqlnd mysql
      oracle oracle
      pcntl pcntl
      postgresql82 postgresql
      postgresql83 postgresql
      pspell pspell
      snmp snmp
      sockets sockets
      sqlite sqlite
      tidy tidy
      } {
      eval [subst {
      variant ${old_variant} description "Obsolete; install ${my_name}-${new_port} port instead" {
      pre-configure {
      ui_msg "The +${old_variant} variant is obsolete. Please install the ${my_name}-${new_port} port instead."
      }
      }
      }]
      }

      Variant: ipc description {Add semaphore, shared memory and IPC functions} {
      configure.args-append --enable-shmop --enable-sysvsem --enable-sysvshm --enable-sysvmsg
      }

      if {![variant_isset apache] && ![variant_isset apache2] && ![variant_isset fastcgi] && ![variant_isset no_web]} {
      default_variants +apache2
      }

      Variant: pear description {Add PEAR} {
      configure.args-delete --without-pear
      configure.args-append --with-pear=${prefix}/lib/php
      destroot.target-append install-pear
      destroot.args-append PHP_PEAR_INSTALL_DIR=${prefix}/lib/php
      post-destroot {
      #nuke pear-stuff in ${destroot}
      system "cd ${destroot} && rm -rf .channels .depdb .depdblock .filemap .lock"

      system "if \[ -f ${prefix}/lib/php/.depdblock \]; then rm -f ${destroot}${prefix}/lib/php/.depdblock; fi"
      system "if \[ -f ${prefix}/lib/php/.depdb \]; then rm -f ${destroot}${prefix}/lib/php/.depdb; fi"
      system "if \[ -f ${prefix}/lib/php/.filemap \]; then rm -f ${destroot}${prefix}/lib/php/.filemap; fi"
      system "if \[ -f ${prefix}/lib/php/.lock \]; then rm -f ${destroot}${prefix}/lib/php/.lock; fi"
      system "if \[ -d ${prefix}/lib/php/.channels \]; then rm -rf ${destroot}${prefix}/lib/php/.channels; fi"
      }
      }

      Variant: suhosin description {Add Suhosin patch} {
      pre-fetch {
      if {"darwin" == ${os.platform} && ${os.major} < 9} {
      ui_error "The suhosin variant requires Mac OS X 10.5 or greater."
      return -code error "incompatible Mac OS X version"
      }
      }
      set suhosin_patch_version ${version}-0.9.8
      set suhosin_patch suhosin-patch-${suhosin_patch_version}.patch.gz
      patch_sites-append http://download.suhosin.org/
      patchfiles-append ${suhosin_patch}
      patchfiles-delete patch-main-fopen_wrappers.c.diff
      checksums-append ${suhosin_patch} md5 a23a3d54e177ac0ad30f78d928ba8177 sha1 f2cdce64a9811a5712bcb038b8d4411f5817abfd rmd160 d01333d55a8288506060053be31c00a24dd14836
      }

      destroot.args INSTALL_ROOT=${destroot}

      destroot.target install-cli install-build install-headers install-programs

      post-destroot {
      # Copy the Apache 1 module.
      if { [variant_isset apache] } {
      xinstall -m 755 -d ${destroot}${prefix}/libexec/apache ${destroot}${prefix}/etc/apache/extra
      xinstall -m 755 ${worksrcpath}/libs/libphp5.so ${destroot}${prefix}/libexec/apache/
      xinstall -m 755 -c ${filespath}/mod_php.conf ${destroot}$prefix/etc/apache/extra
      }

      # Copy the Apache 2.2 module.
      if { [variant_isset apache2] } {
      xinstall -m 755 -d ${destroot}${prefix}/apache2/modules ${destroot}${prefix}/apache2/conf/extra
      xinstall -m 755 ${worksrcpath}/libs/libphp5.so ${destroot}${prefix}/apache2/modules/
      xinstall -m 755 -c ${filespath}/mod_php.conf ${destroot}${prefix}/apache2/conf/extra
      }

      if { [variant_isset fastcgi] } {
      # If we've built an Apache module (any version) then the FastCGI binary
      # will not have been built, so we need to run through the whole process
      # again and build just the FastCGI binary. Keep the options here in sync
      # with the options specified in the apache and apache2 variants.
      if { [variant_isset apache] } {
      if { ![variant_isset macosx] } {
      configure.args-delete --with-apxs=${prefix}/sbin/apxs
      } else {
      configure.args-delete --with-apxs=/usr/sbin/apxs
      }
      }
      if { [variant_isset apache2] } {
      configure.args-delete --with-apxs2=${prefix}/apache2/bin/apxs
      }

      # Run the build again to get the FastCGI binary. Keep the options here
      # in sync with those in the fastcgi variant.
      if { [variant_isset apache] || [variant_isset apache2] } {
      configure.args-delete --disable-cgi
      configure.args-append --enable-cgi
      ui_msg "$UI_PREFIX Configuring ${name} again for fastcgi"
      command_exec configure
      ui_msg "$UI_PREFIX Building ${name} again for fastcgi"
      command_exec build
      ui_msg "$UI_PREFIX Staging ${name} fastcgi into destroot"
      }

      # Copy the FastCGI binary to the bin dir under a new name so it doesn't
      # conflict with the cli version.
      xinstall -m 755 ${worksrcpath}/sapi/cgi/php-cgi ${destroot}${prefix}/bin
      }

      #file rename ${destroot}${prefix}/etc/pear.conf ${destroot}${prefix}/etc/pear.conf.sample

      # Copy the default php.ini files.
      xinstall -m 755 -d ${destroot}${phpinidir}
      xinstall -m 644 -W ${worksrcpath} php.ini-development php.ini-production ${destroot}${phpinidir}
      }

      pre-activate {
      set filepath ${extraphpinidir}/.turd_${name}
      if {[file exists ${filepath}]} {
      delete ${filepath}
      }
      }

      post-activate {
      if {[file exists ${prefix}/etc/php.ini] && ![file exists ${phpinidir}/php.ini]} {
      move ${prefix}/etc/php.ini ${phpinidir}
      ui_msg "Your ${prefix}/etc/php.ini has been moved to ${phpinidir}/php.ini"
      ui_msg ""
      }
      if {![file exists ${phpinidir}/php.ini]} {
      ui_msg "To customize php, copy"
      ui_msg "${phpinidir}/php.ini-development (if this is a development server) or"
      ui_msg "${phpinidir}/php.ini-production (if this is a production server) to"
      ui_msg "${phpinidir}/php.ini and then make changes."
      } else {
      ui_msg "You may need to update your php.ini for any changes that have been made"
      ui_msg "in this version of php. Compare ${phpinidir}/php.ini with"
      ui_msg "${phpinidir}/php.ini-development (if this is a development server) or"
      ui_msg "${phpinidir}/php.ini-production (if this is a production server)."
      }

      if {![variant_isset no_web]} {
      ui_msg ""
      ui_msg "If this is your first install, you need to activate PHP in your web server."
      if {![variant_isset fastcgi]} {
      if {[variant_isset apache]} {
      set moduledir ${prefix}/libexec/modules
      set apxs ${prefix}/apache/bin/apxs
      }
      if {[variant_isset apache2]} {
      set moduledir ${prefix}/apache2/modules
      set apxs ${prefix}/apache2/bin/apxs
      }
      ui_msg ""
      ui_msg "To enable PHP in Apache, run"
      ui_msg " cd ${moduledir}"
      ui_msg " ${apxs} -a -e -n \"${my_name}\" lib${my_name}.so"
      }
      }

      #ui_msg "* copy ${prefix}/etc/pear.conf.sample to ${prefix}/etc/pear.conf"
      }

      Variant: debug description {Enable debug support (useful to analyze a PHP-related core dump)} {
      configure.args-append --enable-debug
      }

      test.run yes

      livecheck.type regex
      livecheck.url ${homepage}downloads.php
      livecheck.regex get/php-(5\\.\[0-9.\]+)\\.tar

    If you haven't already installed Darwin Ports, you can find easy instructions for doing so at the main Darwin Ports page.

    Once Darwin Ports has been installed, in a terminal window and while online, type the following and hit return:


      %  cd /opt/local/bin/portslocation/dports/php5
      % sudo port install php5
      Password:
    You will then be prompted for your root password, which you should enter. You may have to wait for a few minutes while the software is retrieved from the network and installed for you. Y ou should see something that looks similar to:

      ---> Fetching php5
      ---> Verifying checksum for php5
      ---> Extracting php5
      ---> Configuring php5
      ---> Building php5 with target all
      ---> Staging php5 into destroot
      ---> Installing php5
    - Make sure that you do not close the terminal window while Darwin Ports is working. Once the software has been installed, you can find further information about using php5 with these commands:
      %  man php5
      % apropos php5
      % which php5
      % locate php5

     Where to find more information:

    Darwin Ports



    Lightbox this page.