There are a few pre-packaged and pre-compiled versions of PHP for
Mac OS X. This can help in setting up a standard
configuration, but if you need to have a different set of features
(such as a secure server, or a different database driver), you may
need to build PHP and/or your web server yourself. If you are unfamiliar
with building and compiling your own software, it's worth
checking whether somebody has already built a packaged
version of PHP with the features you need.
If you have any other additions (MySQL, GD, etc.), be sure to add them
here. For the --with-apache string, put
in the path to your apache source directory, for example
/src/apache_1.3.12.
Type make and make install. This
will add a directory to your Apache source directory under
src/modules/php4.
You may get a message telling you that libmodphp4.a is out of date. If
so, go to the src/modules/php4
directory inside your apache source directory and run this command:
ranlib libmodphp4.a. Then go back to the root of the
apache source directory and run the above configure
command again. That'll bring the link table up to date. Run
make and make install again.
Copy and rename the php.ini-dist file to your
bin directory from your PHP 4
source directory:
cp php.ini-dist /usr/local/bin/php.ini
or (if your don't have a local directory)
cp php.ini-dist /usr/bin/php.ini.
Those tips are graciously provided by Marc Liyanage.
The PHP module for the Apache web server included in Mac OS X.
This version includes support for the MySQL and PostgreSQL databases.
NOTE: Be careful when you do this, you could screw up your Apache web server!
Do this to install:
Open a terminal window.
Type
wget http://www.diax.ch/users/liyanage/software/macosx/libphp4.so.gz,
wait for the download to finish.
Type gunzip libphp4.so.gz.
Type sudo apxs -i -a -n php4 libphp4.so
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)
Remove the two hash marks (#), then save the file and
quit TextEdit.
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.