Mac How to Install PHP 5 By Macports Detailed With Post-Install Activation

August 18, 2012 | By Duchateaux.

This Article Easily Show How to Install and Getting-Started with PHP5 by MacPorts on Mac OSX 10.5, 10.6 and 10.7.

The Post Include a Careful Explanation of the Article-Install Activation of MacPorts PHP5.

The Content give Focus Only to the Essentials Instructions and Commands to make it Easier to Follow.

PHP on Apple
  1. Open a Terminal Window
    (Press “Enter” to Execute Commands)

  2. Check if MacPorts are Installed:

    which port

    Installing the MacPorts:

    MacPorts Installation Guide
  3. Install PHP5

    sudo su

    If Got “User is Not in Sudoers file” then see: How to Enable sudo

    port install php5

  4. Set the PHP Configuration File

    cp /opt/local/etc/php5/php.ini-development php.ini

    For production you Dispose of Template php.ini-production.

  5. Activate the Module

    cd /opt/local/apache2/modules
    sudo /opt/local/apache2/bin/apxs -a -e -n "php5"

  6. Modify the httpd.conf File

    nano /opt/local/apache2/conf/httpd.conf

    Into the Block Insert.

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
  7. Restart Apache Server

    /opt/local/apache2/bin/httpd -k restart

  8. Make a Testing PHP Script

    nano /opt/local/apache2/htdocs/test.php

    Insert the phpinfo() Directive.

  9. Test your PHP Installation

    Load on Browser the PHP Testing Script.


    You Should be Greeted by the PHP Info Sheet.

QuickChic Theme • Powered by WordPress