1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-23 23:32:18 +01:00

Move/rewrite much of the macOS and Unix install instructions (#3763)

Tried to put more emphasis on how to install from packages (either from distributions or third parties) and for Unix, in particular, move the stuff about compiling from source down a level so new users don't get knocked in the face with it.
This commit is contained in:
Jim Winstead
2024-09-24 13:46:29 -07:00
committed by GitHub
parent dafb1509d0
commit 4cb53ecbd7
8 changed files with 321 additions and 252 deletions

View File

@@ -2,14 +2,14 @@
<!-- $Revision$ -->
<chapter xml:id="install.macosx" xmlns="http://docbook.org/ns/docbook">
<title>Installation on macOS</title>
<para>
This section contains notes and hints specific to installing PHP on macOS.
PHP is bundled with macOS since macOS X (10.0.0) prior to macOS Monterey (12.0.0).
Compiling is similar to the <link linkend="install.unix">Unix installation guide</link>.
</para>
<simpara>
PHP was bundled with macOS in versions 10 and 11, but is not included in versions
since macOS 12 (Monterey). Installation on recent versions either requires using
packages from third-party sources, or compilation from source.
</simpara>
&install.macos.packages;
&install.macos.bundled;
&install.macos.compile;
&install.macos.bundled;
</chapter>
<!-- Keep this comment at the end of the file

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="install.macosx.packages" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Using Packages</title>
<title>Installation on macOS using third-party packages</title>
<simpara>
There are a few pre-packaged and pre-compiled versions of PHP for
macOS. This can help in setting up a standard
@@ -13,49 +13,33 @@
version of PHP with the features you need.
</simpara>
<simpara>
The quickest way to install php on macOS is with homebrew:
An easy way to install PHP on macOS is with the
<link xlink:href="https://brew.sh/">Homebrew</link> packaging manager.
</simpara>
<para>
<orderedlist>
<listitem>
<para>
install homebrew, by following the instructions at <link xlink:href="https://brew.sh/">brew.sh</link>
</para>
</listitem>
<listitem>
<simpara>
brew install php
</simpara>
</listitem>
</orderedlist>
</para>
<orderedlist>
<listitem>
<para>
Install Homebrew by following the instructions on the website.
</para>
</listitem>
<listitem>
<simpara>
<command>brew install php</command>
</simpara>
</listitem>
</orderedlist>
<simpara>
The following alternative resources also offer easy to install packages and
precompiled binaries for PHP on Mac OS:
precompiled binaries for PHP on macOS:
</simpara>
<para>
<itemizedlist>
<listitem>
<simpara>
MacPorts:
<link xlink:href="&url.mac.macports;">&url.mac.macports;</link>
</simpara>
</listitem>
<listitem>
<simpara>
Liip:
<link xlink:href="&url.mac.liip;">&url.mac.liip;</link>
(PHP 5.3 - PHP 7.3; deprecated)
</simpara>
</listitem>
<listitem>
<simpara>
Fink:
<link xlink:href="&url.mac.fink;">&url.mac.fink;</link>
</simpara>
</listitem>
</itemizedlist>
</para>
<simplelist>
<member>
<link xlink:href="&url.mac.macports;">MacPorts</link>
</member>
<member>
<link xlink:href="&url.mac.fink;">Fink</link>
</member>
</simplelist>
</sect1>
<!-- Keep this comment at the end of the file

View File

@@ -1,24 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="install.unix.debian" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Debian GNU/Linux installation notes</title>
<title>Installing from packages on Debian GNU/Linux and related distributions</title>
<para>
This section contains notes and hints specific to installing
PHP on <link xlink:href="&url.debian;">Debian GNU/Linux</link>.
While PHP can be installed from source, it is also available through
packages from <link xlink:href="&url.debian;">Debian GNU/Linux</link>.
This is also true for other distributions based on Debian, such as
Ubuntu, Kali Linux, and Linux Mint.
</para>
<warning>
<para>
Unofficial builds from third-parties are not supported here. Any bugs
should be reported to the Debian team unless they can be reproduced using
the latest builds from our <link xlink:href="&url.php.downloads;">download
area</link>.
</para>
</warning>
&warn.install.third-party-support;
<para>
While the instructions for building PHP on Unix apply to Debian as well,
this manual page contains specific information for other options, such as
using either the <literal>apt</literal> or <literal>aptitude</literal>
commands. This manual page uses these two commands interchangeably.
The packages can be installed using either the <command>apt</command> or
<command>aptitude</command> commands. This manual page uses these two
commands interchangeably.
</para>
<sect2 xml:id="install.unix.debian.apt">
<title>Using APT</title>
@@ -63,7 +57,7 @@
<link linkend="book.mysql">MySQL</link>,
<link linkend="book.curl">cURL</link>,
<link linkend="book.image">GD</link>,
etc. These may also be installed via the <literal>apt</literal> command.
etc. These may also be installed via the <command>apt</command> command.
</simpara>
<example xml:id="install.unix.debian.config.example">
<title>Methods for listing additional PHP packages</title>
@@ -76,12 +70,12 @@
</programlisting>
</example>
<simpara>
The examples will show a lot of packages including several PHP specific ones
like php-cgi, php-cli and php-dev. Determine which are needed
and install them like any other with either <literal>apt</literal>
or <literal>aptitude</literal>. And because Debian performs
dependency checks, it'll prompt for those so for example to install
MySQL and cURL:
The list of packages will include a large number of packages that includes
basic PHP components, such as <literal>php-cgi</literal>,
<literal>php-cli</literal>, and <literal>php-dev</literal>, as well as
many PHP extensions. When extensions are installed, additional packages
will be automatically installed as necessary to satisfy the dependencies
of those packages.
</simpara>
<example xml:id="install.unix.debian.config.example2">
<title>Install PHP with MySQL, cURL</title>
@@ -119,14 +113,6 @@
server was restarted after installation.
</simpara>
</listitem>
<listitem>
<simpara>
There are two basic commands for installing packages on Debian (and other
linux variants): <literal>apt</literal> and <literal>aptitude</literal>.
However, explaining the subtle differences between these commands goes
beyond the scope of this manual.
</simpara>
</listitem>
</itemizedlist>
</sect2>
</sect1>

116
install/unix/dnf.xml Normal file
View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="install.unix.dnf" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Installing from packages on GNU/Linux distributions that use DNF</title>
<simpara>
While PHP can be installed from source, it is also available through
packages on systems that use DNF, such as Red Hat Enterprise Linux,
OpenSUSE, Fedora, CentOS, Rocky Linux, and Oracle Enterprise Linux.
</simpara>
&warn.install.third-party-support;
<simpara>
The packages can be installed using the <command>dnf</command> command.
</simpara>
<sect2 xml:id="install.unix.dnf.packages">
<title>Installing packages</title>
<simpara>
First, note that other related packages may be desired like
<literal>php-pear</literal> for <link xlink:href="&url.pear;">PEAR</link>,
or <literal>php-mysqlnd</literal> for the <link linkend="book.mysqlnd">MySQL
extension</link>.
</simpara>
<simpara>
Second, before installing a package, it's wise to ensure the package list
is up to date. Typically, this is done by running the command
<command>dnf update</command>.
</simpara>
<example xml:id="install.unix.dnf.example">
<title>DNF Install Example</title>
<programlisting role="shell">
<![CDATA[
# dnf install php php-common
]]>
</programlisting>
</example>
<simpara>
DNF will automatically install the configuration for PHP for the web server,
but it may need to be restarted in order for the changes to take effect.
For example:
</simpara>
<example xml:id="install.unix.dnf.example2">
<title>Restarting Apache once PHP is installed</title>
<programlisting role="shell">
<![CDATA[
# sudo systemctl restart httpd
]]>
</programlisting>
</example>
</sect2>
<sect2 xml:id="install.unix.dnf.config">
<title>Better control of configuration</title>
<para>
In the last section, PHP was installed with only core modules. It's
very likely that additional modules will be desired, such as
<simplelist type="inline">
<member><link linkend="book.mysql">MySQL</link></member>
<member><link linkend="book.curl">cURL</link></member>
<member><link linkend="book.image">GD</link></member>
<member>etc.</member>
</simplelist>
These may also be installed via the <command>dnf</command> command.
</para>
<example xml:id="install.unix.dnf.config.example">
<title>Methods for listing additional PHP packages</title>
<programlisting role="shell">
<![CDATA[
# dnf search php
]]>
</programlisting>
</example>
<simpara>
The list of packages will include a large number of packages that includes
basic PHP components, such as <literal>php-cli</literal>,
<literal>php-fpm</literal>, and <literal>php-devel</literal>, as well as
many PHP extensions. When extensions are installed, additional packages
will be automatically installed as necessary to satisfy the dependencies
of those packages.
</simpara>
<example xml:id="install.unix.dnf.config.example2">
<title>Install PHP with MySQL, GD</title>
<programlisting role="shell">
<![CDATA[
# dnf install php-mysqlnd php-gd
]]>
</programlisting>
</example>
<simpara>
DNF will automatically add the appropriate lines to the
different &php.ini; related files like
<filename>/etc/php/8.3/php.ini</filename>,
<filename>/etc/php/8.3/conf.d/*.ini</filename>, etc. and depending on
the extension will add entries similar to <literal>extension=foo.so</literal>.
However, restarting the web server (like Apache) is required before these
changes take affect.
</simpara>
</sect2>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -1,182 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="install.unix" xmlns="http://docbook.org/ns/docbook">
<title>Installation on Unix systems</title>
<para>
This section will guide you through the general configuration and
installation of PHP on Unix systems. Be sure to investigate any
sections specific to your platform or web server before you begin
the process.
</para>
<para>
As our manual outlines in the <link linkend="install.general">General
Installation Considerations</link> section, we are mainly dealing with
web centric setups of PHP in this section, although we will cover
setting up PHP for command line usage as well.
</para>
<para>
There are several ways to install PHP for the Unix platform, either
with a compile and configure process, or through various
pre-packaged methods. This documentation is mainly focused around
the process of compiling and configuring PHP. Many Unix like systems
have some sort of package installation system. This can assist in
setting up a standard configuration, but if you need to have a
different set of features (such as a secure server, or a different
database driver), you may need to build PHP and/or your web server.
If you are unfamiliar with building and compiling your own software,
it is worth checking to see whether somebody has already built a
packaged version of PHP with the features you need.
</para>
<para>
Prerequisite knowledge and software for compiling:
<itemizedlist>
<listitem>
<simpara>
Basic Unix skills (being able to operate "make" and a C
compiler)
</simpara>
</listitem>
<listitem>
<simpara>
An ANSI C compiler
</simpara>
</listitem>
<listitem>
<simpara>
A web server
</simpara>
</listitem>
<listitem>
<simpara>
Any module specific components (such as <acronym>GD</acronym>,
<acronym>PDF</acronym> libs, etc.)
</simpara>
</listitem>
</itemizedlist>
</para>
<chapter xml:id="install.unix" xmlns="http://docbook.org/ns/docbook">
<title>Installation on Unix systems</title>
<simpara>
Most Unix (and Linux) operating systems and distributions have a packaged
version of PHP and extensions available through their packaging system.
There are sections with basic information on installing PHP using those
systems.
</simpara>
<simpara>
For some distributions, there are also third-party repositories of packages
that generally include a wider variety of available versions and extensions.
</simpara>
<simpara>
PHP can also be installed as a component of some third-party application
servers <!-- such as FrankenPHP and Open Swoole-->.
</simpara>
<simpara>
Finally, PHP can always be installed from the source distributions, which
allows the greatest flexibility in choosing what features, extensions, and
server APIs to enable.
There are sections with information about compiling and configuring PHP to
use with different server APIs in particular.
</simpara>
<para>
When building directly from Git sources or after custom modifications you
might also need:
<itemizedlist>
<listitem>
<simpara>
autoconf:
</simpara>
<itemizedlist>
<listitem>
<simpara>
PHP 7.3 and later: 2.68+
</simpara>
</listitem>
<listitem>
<simpara>
PHP 7.2: 2.64+
</simpara>
</listitem>
<listitem>
<simpara>
PHP 7.1 and earlier: 2.59+
</simpara>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<simpara>
automake: 1.4+
</simpara>
</listitem>
<listitem>
<simpara>
libtool: 1.4.x+ (except 1.4.2)
</simpara>
</listitem>
<listitem>
<simpara>
re2c:
</simpara>
<itemizedlist>
<listitem>
<simpara>
PHP 8.3 and later: 1.0.3+
</simpara>
</listitem>
<listitem>
<simpara>
PHP 8.2 and earlier: 0.13.4+
</simpara>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<simpara>
bison:
</simpara>
<itemizedlist>
<listitem>
<simpara>
PHP 7.4 and later: 3.0.0+
</simpara>
</listitem>
<listitem>
<simpara>
PHP 7.3 and earlier: 2.4+ (including Bison 3.x)
</simpara>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</para>
<para>
The initial PHP setup and configuration process is controlled by the
use of the command line options of the <command>configure</command>
script. You could get a list of all available options along with short
explanations running <command>./configure --help</command>.
Our manual documents the different options separately. You will
find the <link linkend="configure.about">core options in the appendix</link>,
while the different extension specific options are described on the
reference pages.
</para>
<para>
When PHP is configured, you are ready to build the module and/or
executables. The command <command>make</command> should
take care of this. If it fails and you can't figure out why, see
the <link linkend="install.problems">Problems section</link>.
</para>
<note>
<para>
Some Unix systems (such as OpenBSD and SELinux) may disallow mapping pages
both writable and executable for security reasons, what is called PaX
MPROTECT or W^X violation protection. This kind of memory mapping is,
however, necessary for PCRE's JIT support, so either PHP has to be built
<link linkend="pcre.installation">without PCRE's JIT support</link>, or the
binary has to be whitelisted by any means provided by the system.
</para>
</note>
<note>
<simpara>
Cross-compiling for ARM with the Android toolchain is currently not supported.
</simpara>
</note>
<!-- web server specific nodes -->
&install.unix.apache2;
&install.unix.nginx;
&install.unix.lighttpd-14;
&install.unix.litespeed;
&install.unix.commandline;
<!-- operating system specific nodes -->
&install.unix.openbsd;
&install.unix.solaris;
<!-- distribution specific nodes -->
&install.unix.debian;
</chapter>
<!-- distribution specific nodes -->
&install.unix.debian;
&install.unix.dnf;
&install.unix.openbsd;
<!-- general from-source instructions -->
&install.unix.source;
<!-- web server specific nodes -->
&install.unix.commandline;
&install.unix.apache2;
&install.unix.nginx;
&install.unix.lighttpd-14;
&install.unix.litespeed;
<!-- operating system specific nodes -->
&install.unix.solaris;
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="install.unix.openbsd" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>OpenBSD installation notes</title>
<title>Installing from packages or ports on OpenBSD</title>
<para>
This section contains notes and hints specific to installing
PHP on <link xlink:href="&url.openbsd;">OpenBSD</link>.

111
install/unix/source.xml Normal file
View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<sect1 xml:id="install.unix.source" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Installing from source on Unix and macOS systems</title>
<para>
Prerequisite software for compiling:
<simplelist>
<member>
<link xlink:href="&url.gnu.make;">GNU <command>make</command></link>
</member>
<member>
A C compiler (as of PHP 8.0.0, C99 compatibility is assumed)
</member>
<member>
A web server
</member>
<member>
Any module specific components (such as <acronym>GD</acronym>,
<acronym>PDF</acronym> libs, etc.)
</member>
</simplelist>
</para>
<para>
When building directly from Git sources or after custom modifications,
these additional tools may be necessary:
<itemizedlist>
<listitem>
<simpara>
<link xlink:href="&url.gnu.autoconf;">autoconf</link>:
</simpara>
<simplelist>
<member>
PHP 7.3 and later: 2.68+
</member>
<member>
PHP 7.2: 2.64+
</member>
<member>
PHP 7.1 and earlier: 2.59+
</member>
</simplelist>
</listitem>
<listitem>
<simpara>
<link xlink:href="&url.re2c;">re2c</link>:
</simpara>
<simplelist>
<member>
PHP 8.3 and later: 1.0.3+
</member>
<member>
PHP 8.2 and earlier: 0.13.4+
</member>
</simplelist>
</listitem>
<listitem>
<simpara>
<link xlink:href="&url.bison;">bison</link>:
</simpara>
<simplelist>
<member>
PHP 7.4 and later: 3.0.0+
</member>
<member>
PHP 7.3 and earlier: 2.4+ (including Bison 3.x)
</member>
</simplelist>
</listitem>
</itemizedlist>
</para>
<simpara>
The initial PHP setup and configuration process is controlled by the
use of the command line options of the <command>configure</command>
script. A list of available options along with short explanations can
be shown by running <command>./configure --help</command>.
This manual documents the different options separately.
The <link linkend="configure.about">core options can be found in the
appendix</link>, while the different extension specific options are
described on the reference pages.
</simpara>
<simpara>
After the configuration script was been run, PHP can be built using
the <command>make</command> command.
The <link linkend="install.problems">Problems section of this
manual</link> has further information about how to handle build
problems.
</simpara>
<note>
<simpara>
Some Unix systems (such as OpenBSD and SELinux) may disallow mapping
pages both writable and executable for security reasons, what is called
<link xlink:href="&url.install.unix.pax-mprotect;">PaX MPROTECT</link>
or <link xlink:href="&url.install.unix.w-x-violation;">W^X violation
protection</link>.
This kind of memory mapping is necessary for PCRE's JIT support, so
either PHP has to be built <link linkend="pcre.installation">without
PCRE's JIT support</link>, or the binary has to be whitelisted by
any means provided by the system.
</simpara>
</note>
<note>
<simpara>
Cross-compiling for ARM with the Android toolchain is currently not supported.
</simpara>
</note>
</sect1>