PHP on FreeBSD 7

Prerequisites:

FreeBSD (Base + Autoconf, Automake, Bash and GCC)
OpenSSL
GD
LibXML
Apache
MySQL
FreeTDS
Basic components Part I and Part II (like bzip, curl and openldap etc.)

Overview:
 Step #1 - Download, Unzip, Untar, Configure, Compile and Install PHP
 Step #2 - Configuration and Testing

Step #1 - Download and Install

PHP - Portable Hypertext Preprocessor

Home: 

 http://www.php.net

# Download (Notes: Users behind a Proxy Server should read this and users without Internet but have a CDRom read this.)
cd /usr/src
fetch http://us2.php.net/distributions/php-5.2.10.tar.gz

Unzip and Untar
tar xvf php-?.?.??.tar.gz

# Stop Apache
/usr/local/sbin/apachectl -k stop

# Change directory
cd php-?.?.??

Configure
./configure --with-apxs2=/usr/local/sbin/apxs --with-mysql=/usr/local --with-openssl=/usr --with-mssql=/usr/local --with-zlib --with-jpeg-dir=/usr/local/lib --with-freetype-dir=/usr/local/lib --enable-exif --with-png-dir=/usr/local/lib --enable-calendar --enable-ftp --with-libxml-dir=/usr/local/lib --with-snmp=/usr/local --enable-fastcgi --enable-magic-quotes --enable-mbstring --enable-sockets --with-gd --enable-gd-native-ttf --enable-soap --enable-sigchild --enable-dbase --with-mssql --with-bz2 --with-kerberos --with-unixODBC --with-ldap --with-curl --with-curlwrappers --with-pdo-dblib --with-cdb --enable-bcmath


# Compile  & Install
cp /usr/local/include/net-snmp/system/freebsd6.h /usr/local/include/net-snmp/system/freebsd7.h
make install clean

 

Step #2 - Configure and Test

php.ini and phpinfo.php

# Copy the "php.ini" file
cp php.ini-dist /usr/local/lib/php.ini

# Edit the Apache configuration file  (Add to the very bottom of the file!)
vi /usr/local/etc/apache22/httpd.conf

# Restart Apache:
/usr/local/sbin/apachectl -k restart

# Create a PHP Info file
vi /usr/local/www/data/phpinfo.php

chown -R www:www /usr/local/www/data

# Test the phpinfo.php file with your web browser:
http://YourServerIP/phpinfo.php

# Add some compatibility for Linux applications by creating a symbolic link
ln -sv /usr/local/bin/php /usr/bin/php

# Edit the "php.ini" to suit your needs!
vi /usr/local/lib/php.ini
#
You may want to add: /usr/local/lib/php to your php.ini include_path
include_path = ".:/usr/local/lib/php"
# Turn on zlib compressed output
# zlib.output_compression = On
# Tune a few other parameters as you see fit
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
register_globals = On
post_max_size = 128M
upload_tmp_dir = /tmp
upload_max_filesize = 128M
sendmail_path = /usr/sbin/sendmail


# Notes:
# PEAR system config file at: /usr/local/etc/pear.conf
# PDO headers: /usr/local/include/php/ext/pdo/

# Use PEAR to install DB
pear install DB