Mac How-to Install PHP 5 by Macports Detailed with Post-Install Activation

August 18th, 2012 by Regaz



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 Understand;)

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 Look: Solution

    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 libphp5.so Module
    cd /opt/local/apache2/modules
    sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
  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

    ?>phpinfo();
    ?>
  9. Test your PHP Installation

    Load on Browser the PHP Testing Script

    http://localhost/test.php

    You Should be Greeted by the PHP Info Sheet.

(Visited 1 times, 1 visits today)

Tags: , , , , , ,