PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Installation on Windows systems> <Installation on Mac OS X
Last updated: Sun, 25 Nov 2007

view this page in

Compiling for MacOS X Client

The following instructions will help you install a PHP module for the Apache web server included in MacOS X. This version includes support for the MySQL and PostgreSQL databases. These instructions are graciously provided by » Marc Liyanage.

Warning

Be careful when you do this, you could screw up your Apache web server!

Do this to install:

  1. Open a terminal window.
  2. Type wget http://www.diax.ch/users/liyanage/software/macosx/libphp4.so.gz , wait for the download to finish.
  3. Type gunzip libphp4.so.gz .
  4. Type sudo apxs -i -a -n php4 libphp4.so
  5. Now type sudo open -a TextEdit /etc/httpd/httpd.conf . TextEdit will open with the web server configuration file. Locate these two lines towards the end of the file: (Use the Find command)

    #AddType application/x-httpd-php .php 
    #AddType application/x-httpd-php-source .phps
    
    Remove the two hash marks (#), then save the file and quit TextEdit.

  6. Finally, type sudo apachectl graceful to restart the web server.

PHP should now be up and running. You can test it by dropping a file into your Sites folder which is called test.php. Into that file, write this line: <?php phpinfo() ?>.

Now open up 127.0.0.1/~your_username/test.php in your web browser. You should see a status table with information about the PHP module.



add a note add a note User Contributed Notes
Compiling for MacOS X Client
mdoyle at cooperationireland dot org
07-Apr-2008 10:54
With OSX 10.5, the bundled version is up to date but didn't come with the modules I needed (notably I wanted the pgsql database extension).

Getting this to work was quite simple in the end, what made it difficult is the build-options for Apache. After searching on google, I found instructions to re-build apache with the following options:

./configure --enable-layout=Darwin --enable-mods-shared=all

(Step 1: download the latest Apache2.2 source files,
 Step 2: extract the tarball
 Step 3: ./configure --enable-layout=Darwin --enable-mods-shared=all
 Step 4: make all
 Step 5: sudo make install)

Without this step, when I rebuilt PHP either directly with the source from the PHP.net site or using MacPorts I was getting an error about the wrong architecture like this one:

httpd: Syntax error on line 114 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/libphp5.so into server: dlopen(/usr/libexec/apache2/libphp5.so, 10): no suitable image found.  Did find:\n\t/usr/libexec/apache2/libphp5.so: mach-o, but wrong architecture

After re-building and Apache with the configuration above and  restarting it, everything worked again and I can now use PostgreSQL from within PHP on my MacBook Pro.
rahul
09-May-2007 03:54
if `wget` isn't installed or not in your path use `curl -O` instead.

Installation on Windows systems> <Installation on Mac OS X
Last updated: Sun, 25 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites