<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/install.unix.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'install.unix.alpine.php',
    1 => 'Installing from packages on Alpine Linux',
    2 => 'Installing from packages on Alpine Linux',
  ),
  'up' => 
  array (
    0 => 'install.unix.php',
    1 => 'Installation on Unix systems',
  ),
  'prev' => 
  array (
    0 => 'install.unix.dnf.php',
    1 => 'Installing from packages on GNU/Linux distributions that use DNF',
  ),
  'next' => 
  array (
    0 => 'install.unix.pacman.php',
    1 => 'Installing from packages on Arch Linux',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'install/unix/alpine.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="install.unix.alpine" class="sect1">
 <h2 class="title">Installing from packages on Alpine Linux</h2>
 <p class="simpara">
  While PHP can be installed from source, it is also available through
  packages on Alpine Linux and derivatives that use the
  <strong class="command">apk</strong> package manager.
 </p>
 <div class="warning"><strong class="warning">Warning</strong>
 <p class="simpara">
  Builds from third-parties are considered unofficial and not directly
  supported by the PHP project. Any bugs encountered should be reported to the
  provider of those unofficial builds unless they can be reproduced using the
  builds from <a href="https://www.php.net/downloads.php" class="link external">&raquo;&nbsp;the official download
  area</a>.
 </p>
</div>
 <p class="simpara">
  The packages can be installed using the <strong class="command">apk</strong> package manager.
 </p>
 <div class="sect2" id="install.unix.alpine.packages">
  <h3 class="title">Installing packages</h3>
  <p class="simpara">
   PHP packages in Alpine Linux include the major version number in their name
   (e.g. <code class="literal">php83</code> for PHP 8.3). In the examples below, replace
   <code class="literal">83</code> with the PHP version available on your Alpine Linux release.
  </p>
  <p class="simpara">
   Before installing a package, ensure the package index is up to
   date by running <strong class="command">apk update</strong>.
  </p>
  <div class="example" id="install.unix.alpine.example">
   <p><strong>Example #1 Alpine Install Example</strong></p>
   <div class="example-contents">
<div class="shellcode"><pre class="shellcode"># apk add php83</pre>
</div>
   </div>

  </div>
  <p class="simpara">
   Alpine does not configure PHP for a web server automatically.
   For FastCGI setups, install <code class="literal">php83-fpm</code> and enable
   the <code class="literal">php-fpm83</code> OpenRC service (note that the package
   name and the service name use different ordering of the version suffix).
   For example:
  </p>
  <div class="example" id="install.unix.alpine.example2">
   <p><strong>Example #2 Enabling and starting PHP-FPM</strong></p>
   <div class="example-contents">
<div class="shellcode"><pre class="shellcode"># apk add php83-fpm
# rc-update add php-fpm83 default
# rc-service php-fpm83 start</pre>
</div>
   </div>

  </div>
 </div>
 <div class="sect2" id="install.unix.alpine.config">
  <h3 class="title">Better control of configuration</h3>
  <p class="para">
   Only the core extensions are installed with the base package. Additional
   extensions such as
   <span class="simplelist"><a href="book.mysql.php" class="link">MySQL</a>, <a href="book.curl.php" class="link">cURL</a>, <a href="book.image.php" class="link">GD</a>, etc.</span>
   can be installed as separate packages.
  </p>
  <div class="example" id="install.unix.alpine.config.example">
   <p><strong>Example #3 Searching for available PHP packages</strong></p>
   <div class="example-contents">
<div class="shellcode"><pre class="shellcode"># apk search php83</pre>
</div>
   </div>

  </div>
  <p class="simpara">
   The list of packages includes the CLI, FPM, and many extensions.
   When extensions are installed, their dependencies are automatically
   resolved.
  </p>
  <div class="example" id="install.unix.alpine.config.example2">
   <p><strong>Example #4 Install PHP with MySQL, GD</strong></p>
   <div class="example-contents">
<div class="shellcode"><pre class="shellcode"># apk add php83-mysqli php83-gd</pre>
</div>
   </div>

  </div>
  <p class="simpara">
   Extensions are automatically enabled when installed; no manual
   <var class="filename">php.ini</var> editing is required. Configuration files are placed in
   <var class="filename">/etc/php83/conf.d/</var>. After installing new
   extensions, PHP-FPM (or the web server) needs to be restarted for
   the changes to take effect.
  </p>
 </div>
</div><?php manual_footer($setup); ?>