Install PHP 5.3.x
The Current PHP5 package in FreeBSD 8.1 contains PHP 5.3.2, which has FastCGI support compiled in. Also, PHP 5.3.2 includes an FPM (FastCGI Process Manager) API which is supposedly more efficient at managing PHP processes. But, for now, we chose not to enable FPM and simply install the precompiled package.
# pkg_add -r php5
Make sure the installed PHP CGI interpreter indeed has FastCGI support:
# php-cgi -v
You should see something like this:
PHP 5.3.2 with Suhosin-Patch (cgi-fcgi) (built: Jun 12 2010 00:11:09)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Notice the cgi-fcgi in parentheses denotes the FastCGI support.
You need a PHP configuration file php.ini located in /usr/local/etc. The file php.ini-production is a good starting point.
# cd /usr/local/etc
# cp php.ini-production php.ini
Now edit time zone setting in php.ini. Open /usr/local/etc/php.ini, and look for date.timezone line in the [Date] section. Modify that line to reflect your server's time zone. For instance,
date.timezone = "America/New_York"
This stops Apache complaining about time zone setting, and is a safe practice.
Next, set session.save_path in php.ini to a proper directory on your server. While this is not necessary for running Joomla! 1.5, it prevents a warning message from showing during installation. Please edit /usr/local/etc/php.ini. In [Session] section, uncomment the line session.save_path and set it to, say, /var/tmp.
session.save_path = "/var/tmp"
Now we need to make PHP work with mod_fcgid. Create a file named fcgid-php.conf in /usr/local/etc/apache22/Includes with the following lines:
# Cause the PHP interpreter to handle files with a .php extension.
AddHandler fcgid-script .php
AddType text/html .php
# Add index.php to the list of files that will be served as directory
# Where to look for the php.ini file?
#DefaultInitEnv PHPRC "/etc/php5/cgi"
# Maximum requests a process handles before it is terminated
# Maximum number of PHP processes
# Number of seconds of idle time before a process is terminated
# Command used to spawn FCGI server processes
FCGIWrapper /usr/local/bin/php-cgi .php
Create a file /usr/local/www/apache22/cgi-bin/phpinfo.php with a single line:
<?php phpinfo(); ?>
Point your browser to http://<your domain name>/cgi-bin/phpinfo.php. It should show the PHP information page if everything works as supposed.
There are some additional PHP extensions which are nice to have. Some of them are required by certain popular Joomla! 1.5 extensions, and some are required in the coming Joomla! 1.6.
# pkg_add -r php5-mysqli
# pkg_add -r php5-mbstring
# pkg_add -r php5-json
# pkg_add -r php5-dom