source: general/prog/php.xml@ 2037ec4

systemd-13485
Last change on this file since 2037ec4 was 2037ec4, checked in by DJ Lucas <dj@…>, 8 years ago

Merge Chapter 13 from trunk.

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/branches/systemd@16861 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 20.9 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6
7 <!ENTITY php-download-http "http://www.php.net/distributions/php-&php-version;.tar.xz">
8 <!--<!ENTITY php-download-ftp "ftp://ftp.isu.edu.tw/pub/Unix/Web/PHP/distributions/php-&php-version;.tar.xz">-->
9 <!ENTITY php-download-ftp " ">
10 <!ENTITY php-md5sum "ce5964672e4ec0b66ff088a6bafde8c7">
11 <!ENTITY php-size "11 MB">
12 <!ENTITY php-buildsize "564 MB (with the tests). Documentation adds 106 MB">
13 <!ENTITY php-time "6.3 SBU (with the tests)">
14]>
15
16<sect1 id="php" xreflabel="PHP-&php-version;">
17 <?dbhtml filename="php.html"?>
18
19 <sect1info>
20 <othername>$LastChangedBy$</othername>
21 <date>$Date$</date>
22 </sect1info>
23
24 <title>PHP-&php-version;</title>
25
26 <indexterm zone="php">
27 <primary sortas="a-PHP">PHP</primary>
28 </indexterm>
29
30 <sect2 role="package">
31 <title>Introduction to PHP</title>
32
33 <para>
34 <application>PHP</application> is the PHP Hypertext Preprocessor.
35 Primarily used in dynamic web sites, it allows for programming code to be
36 directly embedded into the HTML markup. It is also useful as a
37 general purpose scripting language.
38 </para>
39
40 &lfs78_checked;
41
42 <bridgehead renderas="sect3">Package Information</bridgehead>
43 <itemizedlist spacing="compact">
44 <listitem>
45 <para>
46 Download (HTTP): <ulink url="&php-download-http;"/>
47 </para>
48 </listitem>
49 <listitem>
50 <para>
51 Download (FTP): <ulink url="&php-download-ftp;"/>
52 </para>
53 </listitem>
54 <listitem>
55 <para>
56 Download MD5 sum: &php-md5sum;
57 </para>
58 </listitem>
59 <listitem>
60 <para>
61 Download size: &php-size;
62 </para>
63 </listitem>
64 <listitem>
65 <para>
66 Estimated disk space required: &php-buildsize;
67 </para>
68 </listitem>
69 <listitem>
70 <para>
71 Estimated build time: &php-time;
72 </para>
73 </listitem>
74 </itemizedlist>
75
76 <bridgehead renderas="sect3">Additional Downloads</bridgehead>
77 <itemizedlist spacing="compact">
78 <listitem>
79 <para>
80 Pre-built documentation (optional): <ulink
81 url="http://www.php.net/download-docs.php"/>
82 </para>
83 </listitem>
84 </itemizedlist>
85
86 <bridgehead renderas="sect3">PHP Dependencies</bridgehead>
87
88 <bridgehead renderas="sect4">Recommended</bridgehead>
89 <para role="recommended">
90 <xref linkend="apache"/> and
91 <xref linkend="libxml2"/>
92 </para>
93
94 <bridgehead renderas="sect4">Optional System Utilities and Libraries</bridgehead>
95 <para role="optional">
96 <xref linkend="aspell"/>,
97 <xref linkend="enchant"/>,
98 <xref linkend="libxslt"/>,
99 an <xref linkend="server-mail"/> (that provides a
100 <command>sendmail</command> command),
101 <xref linkend="pcre"/>,
102 <xref linkend="pth"/>,
103 <ulink url="http://dmalloc.com/">Dmalloc</ulink>,
104 <ulink url="http://www.net-snmp.org/">Net-SNMP</ulink>,
105 <ulink url="http://www.ossp.org/pkg/lib/mm/">OSSP mm</ulink>,
106 <ulink url="http://re2c.org/">re2c</ulink>, and
107 <ulink url="http://xmlrpc-epi.sourceforge.net/main.php?t=php_about">XMLRPC-EPI</ulink>
108 </para>
109
110 <bridgehead renderas="sect4">Optional Graphics Utilities and Libraries</bridgehead>
111 <para role="optional">
112 <xref linkend="freetype2"/>,
113 <xref linkend="libexif"/>,
114 <xref linkend="libjpeg"/>,
115 <xref linkend="libpng"/>,
116 <xref linkend="libtiff"/>,
117 <xref linkend="x-window-system"/>,
118 <ulink url="http://www.fastio.com/">ClibPDF</ulink>,
119 <ulink url="http://www.adobe.com/devnet/acrobat/fdftoolkit.html">FDF Toolkit</ulink>,
120 <ulink url="https://bitbucket.org/libgd/gd-libgd/downloads">GD</ulink>, and
121 <ulink url="http://fossies.org/linux/misc/t1lib-5.1.2.tar.gz/">t1lib</ulink>
122 </para>
123
124 <bridgehead renderas="sect4">Optional Web Utilities</bridgehead>
125 <para role="optional">
126 <xref linkend="curl"/>,
127 <xref linkend="html-tidy"/>,
128 <ulink url="http://sourceforge.net/projects/caudium/">Caudium</ulink>,
129 <ulink url="http://www.hyperwave.com/">Hyperwave</ulink>,
130 <ulink url="http://www.mnogosearch.org/">mnoGoSearch</ulink>,
131 <ulink url="http://www.roxen.com/products/webserver/">Roxen WebServer</ulink>, and
132 <ulink url="https://wddxnet.codeplex.com/">WDDX</ulink>
133 </para>
134
135 <bridgehead renderas="sect4">Optional Data Management Utilities and Libraries</bridgehead>
136 <para role="optional">
137 <xref linkend="db"/>,
138 <xref linkend="mariadb"/> or <ulink url="http://www.mysql.com/">MySQL</ulink>,
139 <xref linkend="openldap"/>,
140 <xref linkend="postgresql"/>,
141 <xref linkend="sqlite"/>,
142 <xref linkend="unixodbc"/>,
143 <ulink url="http://www.softwareag.com/">Adabas</ulink>,
144 <ulink url="http://www.birdstep.com/">Birdstep</ulink>,
145 <ulink url="http://cr.yp.to/cdb.html">cdb</ulink>,
146 <ulink url="http://www.dbmaker.com/">DBMaker</ulink>,
147 <ulink url="http://www.empress.com/">Empress</ulink>,
148 <ulink url="http://www.frontbase.com/">FrontBase</ulink>,
149 <ulink url="http://www.hughes.com.au/products/msql/">Mini SQL</ulink>,
150 <ulink url="http://www.monetra.com/">Monetra</ulink>, and
151 <ulink url="http://sourceforge.net/projects/qdbm">QDBM</ulink>
152 </para>
153
154 <para>
155 <application>PHP</application> also provides support for many
156 commercial database tools such as <application>Oracle</application>,
157 <application>SAP</application> and
158 <application>ODBC Router</application>.
159 </para>
160
161 <bridgehead renderas="sect4">Optional Security/Encryption Utilities and Libraries</bridgehead>
162 <para role="optional">
163 <xref linkend="openssl"/>,
164 <xref linkend="cyrus-sasl"/>,
165 <xref linkend="mitkrb"/>,
166 <ulink url="http://mcrypt.sourceforge.net/">libmcrypt</ulink>, and
167 <ulink url="http://mhash.sourceforge.net/">mhash</ulink>
168 </para>
169
170 <para condition="html" role="usernotes">
171 User Notes: <ulink url="&blfs-wiki;/php"/>
172 </para>
173
174 </sect2>
175
176 <sect2 role="installation">
177 <title>Installation of PHP</title>
178
179 <para>
180 You can use <application>PHP</application> for server-side
181 scripting, command-line scripting or client-side GUI applications. This
182 book provides instructions for setting up <application>PHP</application>
183 for server-side scripting as it is the most common form.
184 </para>
185
186 <note>
187 <para>
188 <application>PHP</application> has many more
189 <command>configure</command> options that will enable support for
190 various things. You can use <command>./configure --help</command> to
191 see a full list of the available options. Also, use of the
192 <ulink url="http://www.php.net/">PHP web site</ulink>
193 is highly recommended, as their online docs are very good. An example
194 of a <command>configure</command> command that utilizes many of the
195 most common dependencies can be found at <ulink
196 url="&sources-anduin-http;/files/php_configure.txt"/>.
197 </para>
198
199 <para>
200 If, for whatever reason, you don't have <xref linkend="libxml2"/>
201 installed, you need to add <option>--disable-libxml</option> to the
202 <command>configure</command> command in the instructions below. Note
203 that this will prevent the <command>pear</command> command from being
204 built.
205 </para>
206 </note>
207
208 <para>
209 Install <application>PHP</application> by running the following commands:
210 </para>
211
212<screen><userinput>sed -i "s|lsystemd-daemon|lsystemd|g" configure &amp;&amp;
213
214./configure --prefix=/usr \
215 --sysconfdir=/etc \
216 --localstatedir=/var \
217 --datadir=/usr/share/php \
218 --mandir=/usr/share/man \
219 --enable-fpm \
220 --with-fpm-user=apache \
221 --with-fpm-group=apache \
222 --with-fpm-systemd \
223 --with-config-file-path=/etc \
224 --with-zlib \
225 --enable-bcmath \
226 --with-bz2 \
227 --enable-calendar \
228 --enable-dba=shared \
229 --with-gdbm \
230 --with-gmp \
231 --enable-ftp \
232 --with-gettext \
233 --enable-mbstring \
234 --with-readline &amp;&amp;
235make</userinput></screen>
236
237 <para>
238 To test the results, issue: <command>make test</command>. A few
239 tests may fail, in which case you are asked whether you want to send
240 the report to the PHP developpers. If you want to automate the test,
241 you may prefix the command with <command>yes "n" | </command>.
242 </para>
243
244 <para>
245 Now, as the <systemitem class="username">root</systemitem> user:
246 </para>
247
248<!-- dev note: make INSTALL_ROOT=<DESTDIR> install -->
249
250<screen role="root"><userinput>make install &amp;&amp;
251install -v -m644 php.ini-production /etc/php.ini &amp;&amp;
252mv -v /etc/php-fpm.conf{.default,} &amp;&amp;
253
254install -v -m755 -d /usr/share/doc/php-&php-version; &amp;&amp;
255install -v -m644 CODING_STANDARDS EXTENSIONS INSTALL NEWS README* UPGRADING* php.gif \
256 /usr/share/doc/php-&php-version; &amp;&amp;
257ln -v -sfn /usr/lib/php/doc/Archive_Tar/docs/Archive_Tar.txt \
258 /usr/share/doc/php-&php-version; &amp;&amp;
259ln -v -sfn /usr/lib/php/doc/Structures_Graph/docs \
260 /usr/share/doc/php-&php-version;</userinput></screen>
261
262 <para>
263 The pre-built HTML documentation is packaged in two forms: a tarball
264 containing many individual files, useful for quick loading into your
265 browser, and one large individual file, which is useful for using the
266 search utility of your browser. If you downloaded either, or both, of the
267 documentation files, issue the following commands as the
268 <systemitem class='username'>root</systemitem> user to install them (note
269 these instructions assume English docs, modify the tarball names below if
270 necessary).
271 </para>
272
273 <para>
274 For the <quote>Single HTML</quote> file:
275 </para>
276
277<screen role="root"><userinput>install -v -m644 ../php_manual_en.html.gz \
278 /usr/share/doc/php-&php-version; &amp;&amp;
279gunzip -v /usr/share/doc/php-&php-version;/php_manual_en.html.gz</userinput></screen>
280
281 <para>
282 For the <quote>Many HTML files</quote> tarball:
283 </para>
284
285<screen role="root"><userinput>tar -xvf ../php_manual_en.tar.gz \
286 -C /usr/share/doc/php-&php-version; --no-same-owner</userinput></screen>
287
288 </sect2>
289
290 <sect2 role="commands">
291 <title>Command Explanations</title>
292
293 <para>
294 <command>sed -i "s|lsystemd-daemon|lsystemd|g" configure</command>:
295 This command fixes the detection of the systemd library.
296 </para>
297
298 <para>
299 <parameter>--with-datadir=/usr/share/php</parameter>: This works
300 around a bug in the build machinery, which installs some data to a
301 wrong location.
302 </para>
303
304 <para>
305 <parameter>--enable-fpm</parameter>: This parameter allows
306 building the fastCGI Process Manager.
307 </para>
308
309 <para>
310 <parameter>--with-fpm-systemd</parameter>: This parameter allows
311 the FastCGI Process Manager to integrate with systemd.
312 </para>
313
314 <para>
315 <parameter>--with-config-file-path=/etc</parameter>: This parameter
316 makes <application>PHP</application> look for the
317 <filename>php.ini</filename> configuration file in
318 <filename class="directory">/etc</filename>.
319 </para>
320
321 <para>
322 <parameter>--with-zlib</parameter>: This parameter adds
323 support for <application>Zlib</application> compression.
324 </para>
325
326 <para>
327 <parameter>--enable-bcmath</parameter>: Enables
328 <command>bc</command> style precision math functions.
329 </para>
330
331 <para>
332 <parameter>--with-bz2</parameter>: Adds support for
333 <application>Bzip2</application> compression functions.
334 </para>
335
336 <para>
337 <parameter>--enable-calendar</parameter>: This parameter
338 provides support for calendar conversion.
339 </para>
340
341 <para>
342 <parameter>--enable-dba=shared</parameter>: This parameter enables
343 support for database (dbm-style) abstraction layer functions.
344 </para>
345
346 <para>
347 <parameter>--enable-ftp</parameter>: This parameter
348 enables FTP functions.
349 </para>
350
351 <para>
352 <parameter>--with-gettext</parameter>: Enables functions
353 that use <application>Gettext</application> text translation.
354 </para>
355
356 <para>
357 <parameter>--enable-mbstring</parameter>: This parameter
358 enables multibyte string support.
359 </para>
360
361 <para>
362 <parameter>--with-readline</parameter>: This parameter
363 enables command line <application>Readline</application> support.
364 </para>
365
366 <para>
367 <option>--disable-libxml</option>: This option
368 allows building PHP without <application>libxml2</application>
369 installed.
370 </para>
371
372 <para>
373 <option>--with-apxs2</option>: Instead of building the fastCGI process
374 manager, it is possible to build an <application>apache</application>
375 module. This has some performance penalty for heavy loaded servers,
376 but may be easier to set up. This switch is incompatible with the
377 <parameter>--enable-fpm</parameter> and
378 <parameter>--with-fpm-...</parameter> switches.
379 </para>
380
381 <para>
382 <option>--with-mysqli=/usr/bin/mysql_config</option>: This option
383 includes MySQLi support.
384 </para>
385
386 <para>
387 <option>--with-mysql-sock=/run/mysqld/mysqld.sock</option>: Location of
388 the MySQL unix socket pointer.
389 </para>
390
391 <para>
392 <option>--with-pdo-mysql=/usr</option>: This option includes PDO: MySQL
393 support.
394 </para>
395
396 </sect2>
397
398 <sect2 role="configuration">
399 <title>Configuring PHP</title>
400
401 <sect3 id="php-config">
402 <title>Config Files</title>
403
404 <para>
405 <filename>/etc/php.ini</filename>,
406 <filename>/etc/pear.conf</filename>,
407 <filename>/etc/php-fpm.conf</filename>, and
408 <filename>/etc/php-fpm.d/www.conf</filename>
409 </para>
410
411 <indexterm zone="php php-config">
412 <primary sortas="e-etc-php.ini">/etc/php.ini</primary>
413 </indexterm>
414
415 <indexterm zone="php php-config">
416 <primary sortas="e-etc-pear.conf">/etc/pear.conf</primary>
417 </indexterm>
418
419 <indexterm zone="php php-config">
420 <primary sortas="e-etc-php-fpm.d-www.conf">
421 /etc/php-fpm.d/www.conf</primary>
422 </indexterm>
423
424 <indexterm zone="php php-config">
425 <primary sortas="e-etc-php-fpm.conf">/etc/php-fpm.conf</primary>
426 </indexterm>
427
428 </sect3>
429
430 <sect3>
431 <title>Configuration Information</title>
432
433 <para>
434 Without the file <filename>/etc/php-fpm.d/www.conf</filename>,
435 the process manager does not start. However, it is the file
436 <filename>/etc/php-fpm.d/www.conf.default</filename>, that is
437 installed. To solve this, issue as the
438 <systemitem class="username">root</systemitem> user:
439 </para>
440
441<screen role="root"><userinput>cp -v /etc/php-fpm.d/www.conf.default /etc/php-fpm.d/www.conf</userinput></screen>
442
443 <para>
444 The file used as the default <filename>/etc/php.ini</filename>
445 configuration file is recommended by the <application>PHP</application>
446 development team. This file modifies the default behavior of
447 <application>PHP</application>. If no <filename>/etc/php.ini</filename>
448 is used, all configuration settings fall to the defaults. You should
449 review the comments in this file and ensure the changes are acceptable
450 in your particular environment.
451 </para>
452
453 <para>
454 You may have noticed the following from the output of the
455 <command>make install</command> command:
456 </para>
457
458<screen><computeroutput>You may want to add: /usr/lib/php to your php.ini include_path</computeroutput></screen>
459
460 <para>
461 If desired, add the entry using the following command as the
462 <systemitem class="username">root</systemitem> user:
463 </para>
464
465<screen role="root"><userinput>sed -i 's@php/includes"@&amp;\ninclude_path = ".:/usr/lib/php"@' \
466 /etc/php.ini</userinput></screen>
467
468 <para>
469 To enable fastCGI support in the <application>Apache</application>
470 web server, two LoadModule directives must be added to the
471 <filename>httpd.conf</filename> file. They are commented out, so just
472 issue the following command as
473 <systemitem class="username">root</systemitem> user:
474 </para>
475
476<screen role="root"><userinput>sed -i -e '/proxy_module/s/^#//' \
477 -e '/proxy_fcgi_module/s/^#//' \
478 /etc/httpd/httpd.conf</userinput></screen>
479
480 <para>
481 Those modules accept various <command>ProxyPass</command>
482 directives. One possibility is (as the
483 <systemitem class="username">root</systemitem> user):
484 </para>
485
486<screen role="root"><userinput>echo \
487'ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/srv/www/$1' >> \
488/etc/httpd/httpd.conf</userinput></screen>
489
490 <para>
491 Additionally, it may be useful to add an entry for
492 <filename>index.php</filename> to the DirectoryIndex directive of the
493 <filename>httpd.conf</filename> file. Lastly, adding a line to setup the
494 <filename class='extension'>.phps</filename> extension to show
495 highlighted <application>PHP</application> source may be
496 desirable:
497 </para>
498
499<screen><literal>AddType application/x-httpd-php-source .phps</literal></screen>
500
501 <para>
502 You'll need to restart the <application>Apache</application> web server
503 after making any modifications to the <filename>httpd.conf</filename>
504 file.
505 </para>
506
507 </sect3>
508
509 <sect3 id="php-init">
510 <title>Systemd Units</title>
511
512 <para>
513 To start the <command>php-fpm</command> daemon at boot,
514 install the systemd unit from the <xref linkend="bootscripts"/>
515 package by running the following command as the
516 <systemitem class="username">root</systemitem> user:
517 </para>
518
519 <indexterm zone="php php-init">
520 <primary sortas="f-php-fpm">php-fpm</primary>
521 </indexterm>
522
523<screen role="root"><userinput>make install-php-fpm</userinput></screen>
524 </sect3>
525
526 </sect2>
527
528 <sect2 role="content">
529 <title>Contents</title>
530
531 <segmentedlist>
532 <segtitle>Installed Programs</segtitle>
533 <segtitle>Installed Libraries</segtitle>
534 <segtitle>Installed Directories</segtitle>
535
536 <seglistitem>
537 <seg>pear, peardev, pecl, phar (symlink), phar.phar, php,
538 php-cgi, php-config, php-fpm, phpdbg, and phpize</seg>
539 <seg>dba.{so,a} and opcache.{so,a} at
540 /usr/lib/php/extensions/no-debug-non-zts-20151012</seg>
541 <seg>/etc/php-fpm.d, /usr/{include,lib,share}/php and
542 /usr/share/doc/php-&php-version;</seg>
543 </seglistitem>
544 </segmentedlist>
545
546 <variablelist>
547 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
548 <?dbfo list-presentation="list"?>
549 <?dbhtml list-presentation="table"?>
550
551 <varlistentry id="php-prog">
552 <term><command>php</command></term>
553 <listitem>
554 <para>
555 is a command line interface that enables you to parse and
556 execute PHP code.
557 </para>
558 <indexterm zone="php php-prog">
559 <primary sortas="b-php">php</primary>
560 </indexterm>
561 </listitem>
562 </varlistentry>
563
564 <varlistentry id="pear">
565 <term><command>pear</command></term>
566 <listitem>
567 <para>
568 is the PHP Extension and Application Repository (PEAR) package
569 manager.
570 </para>
571 <indexterm zone="php pear">
572 <primary sortas="b-pear">pear</primary>
573 </indexterm>
574 </listitem>
575 </varlistentry>
576
577 <varlistentry id="php-fpm">
578 <term><command>php-fpm</command></term>
579 <listitem>
580 <para>
581 is the fastCGI process manager for PHP.
582 </para>
583 <indexterm zone="php php-fpm">
584 <primary sortas="b-php-fpm">php-fpm</primary>
585 </indexterm>
586 </listitem>
587 </varlistentry>
588
589 <varlistentry id="phpdbg">
590 <term><command>phpdbg</command></term>
591 <listitem>
592 <para>
593 is the interactive PHP debugger.
594 </para>
595 <indexterm zone="php phpdbg">
596 <primary sortas="b-phpdbg">phpdbg</primary>
597 </indexterm>
598 </listitem>
599 </varlistentry>
600
601 </variablelist>
602
603 </sect2>
604
605</sect1>
Note: See TracBrowser for help on using the repository browser.