glfs/general/prog/php.xml

749 lines
26 KiB
XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../../general.ent">
%general-entities;
<!ENTITY php-download-http "https://www.php.net/distributions/php-&php-version;.tar.xz">
<!ENTITY php-download-ftp " ">
<!ENTITY php-md5sum "e0b4a8b8e3c4d0891520424359c33127">
<!ENTITY php-size "11 MB">
<!ENTITY php-buildsize "503 MB (with documentation)">
<!ENTITY php-time "1.5 SBU (with parallelism=4; add 1.6 SBU for tests)">
<!-- Tests were run for 8.0.1 at -j4, had two timeouts as well.
Results were otherwise normal though, so I'm unsure of what caused the
increase in time. -renodr
No timeout for 8.0.2. Tests run at -j4 too. -pierre
No timeouts on 8.0.3 for me this time. -renodr
No timeouts on 8.0.5 -bdubbs
No timeouts, one failure on 8.0.9 -bdubbs
No timeouts on 8.0.10 - thomas
No timeouts on 8.0.11 - thomas
TEST RESULT SUMMARY 8.1.0
Exts skipped : 36
Exts tested : 36
Number of tests : 17060 12551
Tests skipped : 4509 ( 26.4%)
Tests warned : 2 ( 0.0%) ( 0.0%)
Tests failed : 4 ( 0.0%) ( 0.0%)
Expected fail : 28 ( 0.2%) ( 0.2%)
Tests passed : 12517 ( 73.4%) ( 99.7%)
Time taken : 165 seconds
Stats for tests changed slightly for 8.1.1, but not significantly.
Stats for tests changed slightly for 8.1.2, but not significantly.
Tests failed : 1
For 8.1.4, ran tests at -j4. One test still fails.
For 8.1.5, ran tests at -j4. One test still fails.
Running tests at -j4 does nothing. The jobs cound is not passed to the
actual routine running the tests.
For 8.1.7:
Number of tests : 17250 12714
Tests skipped : 4536 ( 26.3%)
Tests warned : 2 ( 0.0%) ( 0.0%)
Tests failed : 1 ( 0.0%) ( 0.0%)
Expected fail : 27 ( 0.2%) ( 0.2%)
Tests passed : 12684 ( 73.5%) ( 99.8%)
Time taken : 162 seconds
The warnings are really XFAIL. The FAIL is ext/phar/tests/bug69958.phpt.
It appears to be mission a test file.
For 8.1.10:
Number of tests : 17315 12768
Tests skipped : 4547 ( 26.3%) - - - - - - - -
Tests warned : 2 ( 0.0%) ( 0.0%)
Tests failed : 5 ( 0.0%) ( 0.0%)
Expected fail : 27 ( 0.2%) ( 0.2%)
Tests passed : 12734 ( 73.5%) ( 99.7%)
Time taken : 162 seconds
For 8.2.0:
Number of tests : 17768 13167
Tests skipped : 4601 ( 25.9%) - - - - - - - -
Tests warned : 3 ( 0.0%) ( 0.0%)
Tests failed : 1 ( 0.0%) ( 0.0%)
Expected fail : 25 ( 0.1%) ( 0.2%)
Tests passed : 13138 ( 73.9%) ( 99.8%)
Time taken : 166 seconds
-->
]>
<sect1 id="php" xreflabel="PHP-&php-version;">
<?dbhtml filename="php.html"?>
<title>PHP-&php-version;</title>
<indexterm zone="php">
<primary sortas="a-PHP">PHP</primary>
</indexterm>
<sect2 role="package">
<title>Introduction to PHP</title>
<para>
<application>PHP</application> 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.
</para>
&lfs113_checked;
<bridgehead renderas="sect3">Package Information</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>
Download (HTTP): <ulink url="&php-download-http;"/>
</para>
</listitem>
<listitem>
<para>
Download (FTP): <ulink url="&php-download-ftp;"/>
</para>
</listitem>
<listitem>
<para>
Download MD5 sum: &php-md5sum;
</para>
</listitem>
<listitem>
<para>
Download size: &php-size;
</para>
</listitem>
<listitem>
<para>
Estimated disk space required: &php-buildsize;
</para>
</listitem>
<listitem>
<para>
Estimated build time: &php-time;
</para>
</listitem>
</itemizedlist>
<bridgehead renderas="sect3">Additional Downloads</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>
Optional pre-built documentation (single file html): <ulink
url="https://www.php.net/distributions/manual/php_manual_en.html.gz"/>
</para>
</listitem>
<listitem>
<para>
Optional pre-built documentation (chunked html): <ulink
url="https://www.php.net/distributions/manual/php_manual_en.tar.gz"/>.
Note that the documentation can be found in languages other than
English at <ulink url="https://www.php.net/download-docs.php"/>
</para>
</listitem>
</itemizedlist>
<bridgehead renderas="sect3">PHP Dependencies</bridgehead>
<bridgehead renderas="sect4">Recommended</bridgehead>
<para role="recommended">
<xref linkend="apache"/> and
<xref linkend="libxml2"/>
</para>
<bridgehead renderas="sect4">Optional System Utilities and Libraries</bridgehead>
<para role="optional">
<xref linkend="aspell"/>,
<xref linkend="enchant"/>,
<xref linkend="libxslt"/>,
an <xref linkend="server-mail"/> (that provides a
<command>sendmail</command> command),
<xref linkend="pcre2"/>,
<xref linkend="pth"/>,
<ulink url="https://wiki.ubuntu.com/AppArmor">AppArmor</ulink>,
<ulink url="https://dmalloc.com/">Dmalloc</ulink>,
<ulink url="http://www.net-snmp.org/">Net-SNMP</ulink>,
<ulink url="https://github.com/kkos/oniguruma">oniguruma</ulink>,
<ulink url="http://www.ossp.org/pkg/lib/mm/">OSSP mm</ulink>,
<ulink url="https://re2c.org/">re2c</ulink>, and
<ulink url="https://xmlrpc-epi.sourceforge.net/main.php?t=php_about">XMLRPC-EPI</ulink>
</para>
<bridgehead renderas="sect4">Optional Graphics Utilities and Libraries</bridgehead>
<para role="optional">
<xref linkend="freetype2"/>,
<xref linkend="libexif"/>,
<xref linkend="libjpeg"/>,
<xref linkend="libpng"/>,
<xref linkend="libtiff"/>,
<xref linkend="libwebp"/>,
<xref linkend="x-window-system"/>,
<!--<ulink url="http://www.fastio.com/">ClibPDF</ulink>, - site asks for username/password-->
<ulink url="https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/">FDF Toolkit</ulink>,
<ulink url="https://github.com/libgd/libgd">GD</ulink>, and
<ulink url="https://www.t1lib.org/">t1lib</ulink>
</para>
<bridgehead renderas="sect4">Optional Web Utilities</bridgehead>
<para role="optional">
<xref linkend="curl"/>,
<xref linkend="tidy-html5"/>,
<ulink url="https://sourceforge.net/projects/caudium/">Caudium</ulink>,
<ulink url="https://www.hyperwave.com/en/">Hyperwave</ulink>,
<ulink url="https://download.roxen.com/6.1/">Roxen WebServer</ulink>, and
<ulink url="https://github.com/Bilal-S/WDDX.net">WDDX</ulink>
</para>
<bridgehead renderas="sect4">Optional Data Management Utilities and Libraries</bridgehead>
<para role="optional">
<xref linkend="db"/> (Note that PHP does not officially support versions
above 5.3),
<xref linkend="libiodbc"/>,
<xref linkend="lmdb"/>,
<xref linkend="mariadb"/> or <ulink url="https://www.mysql.com/">MySQL</ulink>,
<xref linkend="openldap"/>,
<xref linkend="postgresql"/>,
<xref linkend="sqlite"/>,
<xref linkend="unixodbc"/>,
<ulink url="https://www.softwareag.com/en_corporate/platform/adabas-natural.html">Adabas</ulink>,
<ulink url="https://raima.com/product-overview/">Birdstep</ulink>,
<ulink url="https://cr.yp.to/cdb.html">cdb</ulink>,
<ulink url="https://www.dbmaker.com/">DBMaker</ulink>,
<ulink url="http://www.empress.com/">Empress</ulink>,
<ulink url="http://www.frontbase.com/cgi-bin/WebObjects/FBWebSite">FrontBase</ulink>,
<ulink url="https://www.ibm.com/analytics/us/en/db2/">IBM DB2</ulink>,
<ulink url="https://hughestech.com.au/products/msql/">Mini SQL</ulink>,
<ulink url="https://www.monetra.com/">Monetra</ulink>, and
<ulink url="https://sourceforge.net/projects/qdbm">QDBM</ulink>
</para>
<para>
<application>PHP</application> also provides support for many
commercial database tools such as <application>Oracle</application>,
<application>SAP</application> and
<application>ODBC Router</application>.
</para>
<bridgehead renderas="sect4">Optional Security/Encryption Utilities and Libraries</bridgehead>
<para role="optional">
<xref linkend="cyrus-sasl"/>,
<xref linkend="mitkrb"/>,
<ulink url="https://mcrypt.sourceforge.net/">libmcrypt</ulink>, and
<ulink url="https://mhash.sourceforge.net/">mhash</ulink>
</para>
<para condition="html" role="usernotes">
Editor Notes: <ulink url="&blfs-wiki;/php"/>
</para>
</sect2>
<sect2 role="installation">
<title>Installation of PHP</title>
<para>
You can use <application>PHP</application> for server-side
scripting, command-line scripting or client-side GUI applications. This
book provides instructions for setting up <application>PHP</application>
for server-side scripting as it is the most common form.
</para>
<note>
<para>
<application>PHP</application> has many more
<command>configure</command> options that will enable support for
various things. You can use <command>./configure --help</command> to
see a full list of the available options. Also, use of the
<ulink url="https://www.php.net/">PHP web site</ulink>
is highly recommended, as their online docs are very good. An example
of a <command>configure</command> command that utilizes many of the
most common dependencies can be found at <ulink
url="&sources-anduin-http;/files/php_configure.txt"/>.
</para>
<para>
If, for whatever reason, you don't have <xref linkend="libxml2"/>
installed, you need to add <option>--disable-libxml</option> to the
<command>configure</command> command in the instructions below. Note
that this will prevent the <command>pear</command> command from being
built.
</para>
</note>
<para>
Install <application>PHP</application> by running the following commands:
</para>
<screen revision="sysv"><userinput>./configure --prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--datadir=/usr/share/php \
--mandir=/usr/share/man \
--without-pear \
--enable-fpm \
--with-fpm-user=apache \
--with-fpm-group=apache \
--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 &amp;&amp;
make</userinput></screen>
<screen revision="systemd"><userinput>./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 &amp;&amp;
make</userinput></screen>
<para>
To test the results, issue: <command>make test</command>. Several
tests (out of over 16000) 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
<command>yes "n" | </command>.
</para>
<para>
Now, as the <systemitem class="username">root</systemitem> user:
</para>
<!-- dev note: make INSTALL_ROOT=<DESTDIR> install -->
<screen role="root"><userinput>make install &amp;&amp;
install -v -m644 php.ini-production /etc/php.ini &amp;&amp;
install -v -m755 -d /usr/share/doc/php-&php-version; &amp;&amp;
install -v -m644 CODING_STANDARDS* EXTENSIONS NEWS README* UPGRADING* \
/usr/share/doc/php-&php-version;</userinput></screen>
<para>
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
<systemitem class='username'>root</systemitem> user:
</para>
<screen role="root"><userinput>if [ -f /etc/php-fpm.conf.default ]; then
mv -v /etc/php-fpm.conf{.default,} &amp;&amp;
mv -v /etc/php-fpm.d/www.conf{.default,}
fi</userinput></screen>
<para>
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
<systemitem class='username'>root</systemitem> user to install them (note
these instructions assume English docs, modify the tarball names below if
necessary).
</para>
<para>
For the <quote>Single HTML</quote> file:
</para>
<screen role="root"><userinput>install -v -m644 ../php_manual_en.html.gz \
/usr/share/doc/php-&php-version; &amp;&amp;
gunzip -v /usr/share/doc/php-&php-version;/php_manual_en.html.gz</userinput></screen>
<para>
For the <quote>Many HTML files</quote> tarball:
</para>
<screen role="root"><userinput>tar -xvf ../php_manual_en.tar.gz \
-C /usr/share/doc/php-&php-version; --no-same-owner</userinput></screen>
<para>
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:
</para>
<screen role="nodump"><userinput>wget https://pear.php.net/go-pear.phar
php ./go-pear.phar</userinput></screen>
</sect2>
<sect2 role="commands">
<title>Command Explanations</title>
<para>
<parameter>--datadir=/usr/share/php</parameter>: This works
around a bug in the build machinery, which installs some data to a
wrong location.
</para>
<para>
<parameter>--enable-fpm</parameter>: This parameter allows
building the fastCGI Process Manager.
</para>
<para revision="systemd">
<parameter>--with-fpm-systemd</parameter>: This parameter allows
the FastCGI Process Manager to integrate with systemd.
</para>
<para>
<parameter>--without-pear</parameter>: This switch disables
installation of bundled pear software.
</para>
<para>
<parameter>--with-config-file-path=/etc</parameter>: This parameter
makes <application>PHP</application> look for the
<filename>php.ini</filename> configuration file in
<filename class='directory'>/etc</filename>.
</para>
<para>
<parameter>--with-zlib</parameter>: This parameter adds
support for <application>Zlib</application> compression.
</para>
<para>
<parameter>--enable-bcmath</parameter>: Enables
<command>bc</command> style precision math functions.
</para>
<para>
<parameter>--with-bz2</parameter>: Adds support for
<application>Bzip2</application> compression functions.
</para>
<para>
<parameter>--enable-calendar</parameter>: This parameter
provides support for calendar conversion.
</para>
<para>
<parameter>--enable-dba=shared</parameter>: This parameter enables
support for database (dbm-style) abstraction layer functions.
</para>
<para>
<parameter>--enable-ftp</parameter>: This parameter
enables FTP functions.
</para>
<para>
<parameter>--with-gettext</parameter>: Enables functions
that use <application>Gettext</application> text translation.
</para>
<para>
<parameter>--enable-mbstring</parameter>: This parameter
enables multibyte string support.
</para>
<!--
<para>
<parameter>- -disable-mbstring</parameter>: This parameter
disables multibyte string regular expression support. It
requires the external
<ulink url="https://github.com/kkos/oniguruma">oniguruma</ulink>
library.
</para>
-->
<para>
<parameter>--with-readline</parameter>: This parameter
enables command line <application>Readline</application> support.
</para>
<para>
<option>--disable-libxml</option>: This option
allows building PHP without <application>libxml2</application>
installed.
</para>
<para>
<option>--with-apxs2</option>: Instead of building the fastCGI process
manager, it is possible to build an <application>apache</application>
module. This has some performance penalty for heavy loaded servers,
but may be easier to set up. This switch is incompatible with the
<parameter>--enable-fpm</parameter> and
<parameter>--with-fpm-...</parameter> switches.
</para>
<para>
<option>--with-mysqli=shared</option>: This option includes MySQLi
support.
</para>
<para>
<option>--with-mysql-sock=/run/mysqld/mysqld.sock</option>: Location of
the MySQL unix socket pointer.
</para>
<para>
<option>--with-pdo-mysql=shared</option>: This option includes PDO:
MySQL support.
</para>
<para>
<option>--with-tidy=shared</option>: This option includes tidy library
support.
</para>
</sect2>
<sect2 role="configuration">
<title>Configuring PHP</title>
<sect3 id="php-config">
<title>Config Files</title>
<para>
<filename>/etc/php.ini</filename>,
<filename>/etc/pear.conf</filename>,
<filename>/etc/php-fpm.conf</filename>, and
<filename>/etc/php-fpm.d/www.conf</filename>
</para>
<indexterm zone="php php-config">
<primary sortas="e-etc-php.ini">/etc/php.ini</primary>
</indexterm>
<indexterm zone="php php-config">
<primary sortas="e-etc-pear.conf">/etc/pear.conf</primary>
</indexterm>
<indexterm zone="php php-config">
<primary sortas="e-etc-php-fpm.d-www.conf">
/etc/php-fpm.d/www.conf</primary>
</indexterm>
<indexterm zone="php php-config">
<primary sortas="e-etc-php-fpm.conf">/etc/php-fpm.conf</primary>
</indexterm>
</sect3>
<sect3>
<title>Configuration Information</title>
<para>
The file used as the default <filename>/etc/php.ini</filename>
configuration file is recommended by the <application>PHP</application>
development team. This file modifies the default behavior of
<application>PHP</application>. If no <filename>/etc/php.ini</filename>
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.
</para>
<para>
The fastCGI process manager uses the configuration file
<filename>/etc/php-fpm.conf</filename>. The default file shipped with
PHP includes all the <filename>/etc/php-fpm.d/*.conf</filename> in turn.
There is a shipped <filename>/etc/php-fpm.d/www.conf</filename> file,
that contains the parameters related to the interaction with the Apache
Web server.
</para>
<para>
You may have noticed the following from the output of the
<command>make install</command> command:
</para>
<screen><computeroutput>You may want to add: /usr/lib/php to your php.ini include_path</computeroutput></screen>
<para>
If desired, add the entry using the following command as the
<systemitem class="username">root</systemitem> user:
</para>
<screen role="root"><userinput>sed -i 's@php/includes"@&amp;\ninclude_path = ".:/usr/lib/php"@' \
/etc/php.ini</userinput></screen>
<para>
To enable fastCGI support in the <application>Apache</application>
web server, two LoadModule directives must be added to the
<filename>httpd.conf</filename> file. They are commented out, so just
issue the following command as
<systemitem class="username">root</systemitem> user:
</para>
<screen role="root"><userinput>sed -i -e '/proxy_module/s/^#//' \
-e '/proxy_fcgi_module/s/^#//' \
/etc/httpd/httpd.conf</userinput></screen>
<para>
Those modules accept various <command>ProxyPass</command>
directives. One possibility is (as the
<systemitem class="username">root</systemitem> user):
</para>
<screen role="root"><userinput>echo \
'ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/srv/www/$1' >> \
/etc/httpd/httpd.conf</userinput></screen>
<para>
Additionally, it may be useful to add an entry for
<filename>index.php</filename> to the DirectoryIndex directive of the
<filename>httpd.conf</filename> file. Lastly, adding a line to set up the
<filename class='extension'>.phps</filename> extension to show
highlighted <application>PHP</application> source may be
desirable:
</para>
<screen><literal>AddType application/x-httpd-php-source .phps</literal></screen>
<para>
You'll need to restart the <application>Apache</application> web server
after making any modifications to the <filename>httpd.conf</filename>
file.
</para>
</sect3>
<sect3 id="php-init">
<title><phrase revision="sysv">Boot Script</phrase>
<phrase revision="systemd">Systemd Unit</phrase></title>
<para revision="sysv">
To automatically start the <command>php-fpm</command> daemon when the
system is rebooted, install the
<filename>/etc/rc.d/init.d/php</filename> bootscript from the
<xref linkend="bootscripts"/> package as the
<systemitem class="username">root</systemitem> user:
</para>
<para revision="systemd">
To start the <command>php-fpm</command> daemon at boot,
install the systemd unit from the <xref linkend="systemd-units"/>
package by running the following command as the
<systemitem class="username">root</systemitem> user:
</para>
<indexterm zone="php php-init">
<primary sortas="f-php">php</primary>
</indexterm>
<screen role="root" revision="sysv"><userinput>make install-php</userinput></screen>
<screen role="root" revision="systemd"><userinput>make install-php-fpm</userinput></screen>
</sect3>
</sect2>
<sect2 role="content">
<title>Contents</title>
<segmentedlist>
<segtitle>Installed Programs</segtitle>
<segtitle>Installed Libraries</segtitle>
<segtitle>Installed Directories</segtitle>
<seglistitem>
<seg><!-- not built anymore pear, peardev, pecl,-->
phar (symlink), phar.phar, php,
php-cgi, php-config, php-fpm, phpdbg, and phpize</seg>
<seg>dba.so and opcache.so in
/usr/lib/php/extensions/no-debug-non-zts-20220829</seg>
<seg>/etc/php-fpm.d, /usr/{include,lib,share}/php, and
/usr/share/doc/php-&php-version;</seg>
</seglistitem>
</segmentedlist>
<variablelist>
<bridgehead renderas="sect3">Short Descriptions</bridgehead>
<?dbfo list-presentation="list"?>
<?dbhtml list-presentation="table"?>
<varlistentry id="php-prog">
<term><command>php</command></term>
<listitem>
<para>
is a command line interface that enables you to parse and
execute PHP code
</para>
<indexterm zone="php php-prog">
<primary sortas="b-php">php</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="pear">
<term><command>pear</command></term>
<listitem>
<para>
is the PHP Extension and Application Repository (PEAR) package
manager. This isn't installed by default
</para>
<indexterm zone="php pear">
<primary sortas="b-pear">pear</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="php-fpm">
<term><command>php-fpm</command></term>
<listitem>
<para>
is the fastCGI process manager for PHP
</para>
<indexterm zone="php php-fpm">
<primary sortas="b-php-fpm">php-fpm</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="phpdbg">
<term><command>phpdbg</command></term>
<listitem>
<para>
is the interactive PHP debugger
</para>
<indexterm zone="php phpdbg">
<primary sortas="b-phpdbg">phpdbg</primary>
</indexterm>
</listitem>
</varlistentry>
</variablelist>
</sect2>
</sect1>