#### Beyond Linux® From Scratch (systemd Edition) - Version r13.0-491

### Chapter 13. Programming

- Prev

  Perl Module Dependencies

- Next

  Python-3.14.4

- Up
- Home

# PHP-8.5.5

## 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. It is also useful as a general purpose scripting language.

### Note

Development versions of BLFS may not build or run some packages properly if LFS or dependencies have been updated since the most recent stable versions of the books.

### Package Information

- Download (HTTP): https://www.php.net/distributions/php-8.5.5.tar.xz

- Download MD5 sum: 75841bde77d44ec53584fec41dde43a4

- Download size: 14 MB

- Estimated disk space required: 640 MB (with tests)

- Estimated build time: 1.5 SBU (add 2.5 SBU for tests; both with parallelism=4)

### Additional Downloads

- Optional pre-built documentation (single file html): https://www.php.net/distributions/manual/php_manual_en.html.gz

- Optional pre-built documentation (chunked html): https://www.php.net/distributions/manual/php_manual_en.tar.gz. Note that the documentation can be found in languages other than English at https://www.php.net/download-docs.php

### PHP Dependencies

#### Recommended

Apache-2.4.66 and libxml2-2.15.3

#### Optional System Utilities and Libraries

Aspell-0.60.8.2, enchant-2.8.16, libxslt-1.1.45, an MTA (that provides a sendmail command), AppArmor, Dmalloc, Net-SNMP, oniguruma, OSSP mm, re2c, and XMLRPC-EPI

#### Optional Graphics Utilities and Libraries

FreeType-2.14.3, libexif-0.6.26, libjpeg-turbo-3.1.4.1, libpng-1.6.58, libtiff-4.7.1, libwebp-1.6.0, a graphical environment, FDF Toolkit, GD, and t1lib

#### Optional Web Utilities

cURL-8.19.0, tidy-html5-5.8.0, Caudium, Hyperwave, and WDDX

#### Optional Data Management Utilities and Libraries

lmdb-0.9.35, MariaDB-11.8.6 or MySQL, OpenLDAP-2.6.13, PostgreSQL-18.3, unixODBC-2.3.14, Berkeley DB (deprecated) Adabas, Birdstep, cdb, DBMaker, Empress, FrontBase, IBM DB2, libiodbc, Mini SQL, Monetra, and QDBM

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

#### Optional Security/Encryption Utilities and Libraries

Cyrus SASL-2.1.28, libmcrypt, and mhash

Editor Notes: https://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

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 https://anduin.linuxfromscratch.org/BLFS/files/php_configure.txt.

If, for whatever reason, you don't have libxml2-2.15.3 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:

    ./configure --prefix=/usr                \
                --sysconfdir=/etc            \
                --localstatedir=/var         \
                --datadir=/usr/share/php     \
                --mandir=/usr/share/man      \
                --enable-fpm                 \
                --without-pear               \
                --with-fpm-user=apache       \
                --with-fpm-group=apache      \
                --with-fpm-systemd           \
                --with-config-file-path=/etc \
                --with-zlib                  \
                --enable-bcmath              \
                --with-bz2                   \
                --enable-calendar            \
                --enable-dba=shared          \
                --with-gdbm                  \
                --with-gmp                   \
                --enable-ftp                 \
                --with-gettext               \
                --enable-mbstring            \
                --disable-mbregex            \
                --with-readline              &&
    make

To test the results, issue: make test. Some tests (out of over 20000) may fail, in which case you are asked whether you want to send the report to the PHP developers. If you want to automate the test, you may prefix the command with yes "n" | .

Now, as the `root` user:

    make install                                     &&
    install -v -m644 php.ini-production /etc/php.ini &&

    install -v -m755 -d /usr/share/doc/php-8.5.5 &&
    install -v -m644    CODING_STANDARDS* EXTENSIONS NEWS README* UPGRADING* \
                        /usr/share/doc/php-8.5.5

The default configuration files for the fastCGI process manager are installed only if they do not already exist on the system. If this is the first installation, they should be renamed, as the `root` user:

    if [ -f /etc/php-fpm.conf.default ]; then
      mv -v /etc/php-fpm.conf{.default,} &&
      mv -v /etc/php-fpm.d/www.conf{.default,}
    fi

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-8.5.5 &&
    gunzip -v /usr/share/doc/php-8.5.5/php_manual_en.html.gz

For the “Many HTML files” tarball:

    tar -xvf ../php_manual_en.tar.gz \
        -C /usr/share/doc/php-8.5.5 --no-same-owner

The bundled pear is not installed because of a bug which might pollute the filesystem with several hidden files and directories. If pear is needed, execute the following commands to install it:

    wget https://pear.php.net/go-pear.phar
    php ./go-pear.phar

## Command Explanations

`--datadir=/usr/share/php`: This works around a bug in the build machinery, which installs some data to a wrong location.

`--enable-fpm`: This parameter allows building the fastCGI Process Manager.

`--with-fpm-systemd`: This parameter allows the FastCGI Process Manager to integrate with systemd.

`--without-pear`: This switch disables installation of bundled pear software.

`--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=shared`: This parameter enables support for database (dbm-style) abstraction layer functions.

`--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-readline`: This parameter enables command line Readline support.

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

`--with-apxs2`: Instead of building the fastCGI process manager, it is possible to build an apache module. This has some performance penalty for heavy loaded servers, but may be easier to set up. This switch is incompatible with the `--enable-fpm` and `--with-fpm-...` switches.

`--with-mysqli=shared`: This option includes MySQLi support.

`--with-mysql-sock=/run/mysqld/mysqld.sock`: Location of the MySQL unix socket pointer.

`--with-pdo-mysql=shared`: This option includes PDO: MySQL support.

`--with-tidy=shared`: This option includes tidy library support.

## Configuring PHP

### Config Files

`/etc/php.ini`, `/etc/pear.conf`, `/etc/php-fpm.conf`, and `/etc/php-fpm.d/www.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.

The fastCGI process manager uses the configuration file `/etc/php-fpm.conf`. The default file shipped with PHP includes all the `/etc/php-fpm.d/*.conf` in turn. There is a shipped `/etc/php-fpm.d/www.conf` file, that contains the parameters related to the interaction with the Apache Web server.

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 fastCGI support in the Apache web server, two LoadModule directives must be added to the `httpd.conf` file. They are commented out, so just issue the following command as `root` user:

    sed -i -e '/proxy_module/s/^#//'      \
           -e '/proxy_fcgi_module/s/^#//' \
           /etc/httpd/httpd.conf

Those modules accept various ProxyPass directives. One possibility is (as the `root` user):

    echo \
    'ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/srv/www/$1' >> \
    /etc/httpd/httpd.conf

Additionally, it may be useful to add an entry for `index.php` to the DirectoryIndex directive of the `httpd.conf` file. Lastly, adding a line to set up 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.

### Systemd Unit

To start the php-fpm daemon at boot, install the systemd unit from the blfs-systemd-units-20251204 package by running the following command as the `root` user:

    make install-php-fpm

## Contents

Installed Programs: phar (symlink), phar.phar, php, php-cgi, php-config, php-fpm, phpdbg, and phpize
Installed Libraries: dba.so and opcache.so in /usr/lib/php/extensions/no-debug-non-zts-20240924
Installed Directories: /etc/php-fpm.d, /usr/{include,lib,share}/php, and /usr/share/doc/php-8.5.5

### 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. This isn't installed by default
php-fpm | is the fastCGI process manager for PHP
phpdbg | is the interactive PHP debugger

- Prev

  Perl Module Dependencies

- Next

  Python-3.14.4

- Up
- Home