Carlsbad Cubes Wolf Paulus

mac-osx

Enabling PHP 5.2.5 on Mac OS X 10.5.2 [Client]
By Wolf Paulus <wolf@wolfpaulus.com>

Posted Monday, March 31st, 2008

Getting the pre-complied PHP Apache Module from Marc Liyanage's site was always the preferred way to get a fresh PHP distribution on your Mac. However, creating 4-way binaries (32- and 64-bit versions for G4/G5 and Intel CoreDuo / Core-2-Duo processors) seems to be broken and if Apache is running in the more efficient 64-bit mode, installing the PHP module not only doesn't work, it will also break Apache. However, there is an easier way to get PHP working with your Apache Server on the Mac.

Apache 2.2.8

Starting Apache is as easy as opening System Preferences - Sharing and checking the box next to Web Sharing. After that's done, open your Web browser and browser to http://127.0.0.1 (or http://localhost, or http://computername.local) to see the global Apache start page or go to http://127.0.0.1/~username (or http://localhost/~username, or http://computername.local/~username) to browse the content of your own site folder (/Users/username/Sites).

PHP 5.2.5

To enable PHP you need to edit Apache's protected configuration file, which can be done using the terminal or an editor application like the free TextWrangler.

Apache with PHP

To see it all working, create a new text file in your site folder (/Users/username/Sites) and name it phpinfo.php




.. and browse to http://127.0.0.1/~username/phpinfo.php

Enable PHP code in HTML

Enabling PHP code interpretation/pre-processing in HTML files, has a minor performance impact on your server, but allows you to write PHP code inside of regular HTML pages (htm or html extension).
To enable this, we simply have to add this line to the PHP extension mappings, whose availability we had checked earlier.

Back in terminal enter:
sudo pico /etc/apache2/other/php5.conf
Before saving with Ctrl-O, the configuration file should look something like this:






Disclosure: This blog is written and edited by me, it contains my words and my opinions only, and does not contain any content which might present a conflict of interest.
I am not compensated to provide opinion on products, services, websites and various other topics. This blog does not accept any form of cash advertising, sponsorship, or paid topic insertions. However, I will and do accept and keep free products, services, and other forms of compensation from companies and organizations. All advertising is in the form of advertisements generated by a third party ad network and identified as such.
I will only endorse products or services that I believe, based on my expertise, are worthy of such endorsement. Any product claim, statistic, quote or other representation about a product or service should be verified with the manufacturer or provider.

Published on: Monday, March 31st, 2008  •  Category: [mac-osx]

Article URL : http://wolfpaulus.com/journal/mac-osx/phposx.html