PHP-5.1.4

Introduction to PHP

PHP is the PHP Hypertext Preprocessor. Primarily used in dynamic web sites, it allows for programming code to be directly embedded into the HTML markup.

Package Information

Additional Downloads

PHP Dependencies

Required

Apache-2.2.2

Recommended

Optional System Utilities and Libraries

libxslt-1.1.17, GMP-4.2, PCRE-6.7, Aspell-0.60.4, pkg-config-0.20, expat-2.0.0 (deprecated alternative to libxml2-2.6.26), OSSP mm, Net-SNMP, GNU Pth, re2c, XMLRPC-EPI, Dmalloc, recode, and an MTA (that provides a sendmail command)

Optional Graphics Utilities and Libraries

libjpeg-6b, LibTIFF-3.8.2, libpng-1.2.12, libexif-0.6.13, FreeType-2.1.10, X Window System, ClibPDF, GD, t1lib, and FDF Toolkit

Optional Web Utilities

cURL-7.15.3, HTML Tidy-051026, mnoGoSearch, Hyperwave, Roxen WebServer, Caudium, and WDDX

Optional Data Management Utilities and Libraries

OpenLDAP-2.3.27, GDBM-1.8.3, MySQL-5.0.21, PostgreSQL-8.1.3, unixODBC-2.2.11, QDBM, cdb, SQLite, Mini SQL, Empress, Birdstep, DBMaker, Adabas, FrontBase, and Monetra

PHP also provides support for many commercial database tools such as Oracle, SAP and ODBC Router.

Optional Security/Encryption Utilities and Libraries

OpenSSL-0.9.8d, Cyrus SASL-2.1.21, MIT Kerberos V5-1.6 or Heimdal-0.7.2, libmcrypt, and mhash

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/php

Installation of PHP

You can use PHP for server-side scripting, command-line scripting or client-side GUI applications. This book provides instructions for setting up PHP for server-side scripting as it is the most common form.

[Note]

Note

PHP has many more configure options that will enable support for various things. You can use ./configure --help to see a full list of the available options. Also, use of the PHP web site is highly recommended, as their online docs are very good. An example of a configure command that utilizes many of the most common dependencies can be found at http://anduin.linuxfromscratch.org/files/BLFS/php_configure.txt.

If, for whatever reason, you don't have libxml2-2.6.26 installed, you need to add --disable-libxml to the configure command in the instructions below. Note that this will prevent the pear command from being built.

Install PHP by running the following commands:

sed -i 's/const char \*errpfx,/const DB_ENV *dbenv, & const/' \
    ext/dba/dba_db4.c &&
./configure --prefix=/usr \
            --sysconfdir=/etc \
            --with-apxs2 \
            --enable-force-cgi-redirect \
            --enable-discard-path \
            --with-config-file-path=/etc \
            --with-zlib \
            --enable-bcmath \
            --with-bz2 \
            --enable-calendar \
            --enable-dba \
            --enable-exif \
            --enable-ftp \
            --with-gettext \
            --enable-mbstring \
            --with-ncurses \
            --with-readline &&
make

To test the results, issue: make test. Three of the (over 1600) tests are known to fail: an iconv stream filter test (ext/iconv/tests/iconv_stream_filter.phpt) and two MBString function overload tests (ext/mbstring/tests/overload01.phpt and ext/mbstring/tests/overload02.phpt). Additionally, if you have the unixODBC package installed and linked into the build, you may see many failures related to it.

Now, as the root user:

make install &&
install -v -m644 php.ini-recommended /etc/php.ini &&
install -v -m755 -d /usr/share/doc/php-5.1.4 &&
install -v -m644 CODING_STANDARDS EXTENSIONS INSTALL NEWS \
                 README* TODO* UPGRADING php.gif \
    /usr/share/doc/php-5.1.4 &&
ln -v -s /usr/lib/php/doc/Archive_Tar/docs/Archive_Tar.txt \
    /usr/share/doc/php-5.1.4

The pre-built HTML documentation is packaged in two forms: a tarball containing many individual files, useful for quick loading into your browser, and one large individual file, which is useful for using the search utility of your browser. If you downloaded either, or both, of the documentation files, issue the following commands as the root user to install them (note these instructions assume English docs, modify the tarball names below if necessary).

For the “Single HTML” file:

install -v -m644 ../php_manual_en.html.gz \
    /usr/share/doc/php-5.1.4 &&
gunzip -v /usr/share/doc/php-5.1.4/php_manual_en.html.gz

For the “Many HTML files” tarball:

tar -xvf ../php_manual_en.tar.gz -C /usr/share/doc/php-5.1.4 &&
chown -v -R root:root /usr/share/doc/php-5.1.4/html

Command Explanations

sed -i '...' ext/dba/dba_db4.c: This command is used to fix an issue with the use of Berkeley DB >= 4.3.x.

--with-apxs2: This parameter builds the Apache HTTPD 2.0 module.

--with-config-file-path=/etc: This parameter makes PHP look for the php.ini configuration file in /etc.

--with-zlib: This parameter adds support for Zlib compression.

--enable-bcmath: Enables bc style precision math functions.

--with-bz2: Adds support for Bzip2 compression functions.

--enable-calendar: This parameter provides support for calendar conversion.

--enable-dba: This parameter enables support for database (dbm-style) abstraction layer functions.

--enable-exif: Enables functions to access metadata from images.

--enable-ftp: This parameter enables FTP functions.

--with-gettext: Enables functions that use Gettext text translation.

--enable-mbstring: This parameter enables multibyte string support.

--with-ncurses: Provides ncurses terminal independent cursor handling.

--with-readline: This parameter enables command line Readline support.

--disable-libxml: This parameter allows building PHP without libxml2 installed.

Configuring PHP

Config Files

/etc/php.ini and /etc/pear.conf

Configuration Information

The file used as the default /etc/php.ini configuration file is recommended by the PHP development team. This file modifies the default behavior of PHP. If no /etc/php.ini is used, all configuration settings fall to the defaults. You should review the comments in this file and ensure the changes are acceptable in your particular environment.

You may have noticed the following from the output of the make install command:

You may want to add: /usr/lib/php to your php.ini include_path

If desired, add the entry using the following command as the root user:

sed -i 's@php/includes"@&\ninclude_path = ".:/usr/lib/php"@' \
    /etc/php.ini

To enable PHP support in the Apache web server, a new LoadModule (which should be handled automatically by the make install command) and AddType directives must be added to the httpd.conf file:

LoadModule php5_module lib/apache/libphp5.so
AddType application/x-httpd-php .php

Additionally, it can be useful to add an entry for index.php to the DirectoryIndex directive of the httpd.conf file. Lastly, adding a line to setup the .phps extension to show highlighted PHP source may be desirable:

AddType application/x-httpd-php-source .phps

You'll need to restart the Apache web server after making any modifications to the httpd.conf file.

Contents

Installed Programs: pear, peardev, pecl, php, php-config and phpize
Installed Library: libphp5.so Apache module
Installed Directories: /usr/include/php, /usr/lib/php and /usr/share/doc/php-5.1.4

Short Descriptions

php

is a command line interface that enables you to parse and execute PHP code.

pear

is the PHP Extension and Application Repository (PEAR) package manager.

Last updated on 2007-01-17 06:57:47 -0600