<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/install.windows.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'install.windows.apache2.php',
    1 => 'Installation for Apache 2.x on Windows systems',
    2 => 'Installation for Apache 2.x on Windows systems',
  ),
  'up' => 
  array (
    0 => 'install.windows.php',
    1 => 'Встановлення в системах Windows',
  ),
  'prev' => 
  array (
    0 => 'install.windows.manual.php',
    1 => 'Manual installation of pre-built binaries',
  ),
  'next' => 
  array (
    0 => 'install.windows.iis.php',
    1 => 'Installation with IIS for Windows',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'install/windows/apache2.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="install.windows.apache2" class="sect1">
 <h2 class="title">Installation for Apache 2.x on Windows systems</h2>
 <p class="para">
  This section contains notes and hints specific to Apache 2.x installs
  of PHP on Microsoft Windows systems.
 </p>
 <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
  <p class="para">
   Please read the <a href="install.windows.manual.php" class="link">manual
   installation steps</a> first!
  </p>
 </p></blockquote>

 <p class="para">
  It is strongly recommended to consult the
  <a href="http://httpd.apache.org/docs/current/" class="link external">&raquo;&nbsp;Apache Documentation</a>
  to get have  a basic understanding of the Apache 2.x Server.
  Also consider reading the
  <a href="http://httpd.apache.org/docs/current/platform/windows.html" class="link external">&raquo;&nbsp;Windows specific notes</a>
  for Apache 2.x before reading on here.
 </p>

 <p class="para">
  Download the most recent version of
  <a href="https://www.apachelounge.com/download/" class="link external">&raquo;&nbsp;Apache 2.x</a>
  and a fitting PHP version. Follow the
  <a href="install.windows.manual.php" class="link">Manual Installation Steps</a>
  and come back to go on with the integration of PHP and Apache.
 </p>

 <p class="para">
  There are three ways to set up PHP to work with Apache 2.x on Windows.
  PHP can be run as a handler, as a CGI, or under FastCGI.
 </p>

 <blockquote class="note"><p><strong class="note">Зауваження</strong>: <span class="simpara">Варто зауважити, що у 
файлі налаштувань Apache на Windows значення шляху (напр.
<var class="filename">c:\directory\file.ext</var>) мають містити звичайні слеші, а не
зворотні: <var class="filename">c:/directory/file.ext</var>. Слеш в кінці також є
обов&#039;язковим, коли шлях веде до теки.</span></p></blockquote>

 <div class="sect2" id="install.windows.apache2.module">
  <h3 class="title">Installing as an Apache handler</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <span class="simpara">
    When using the apache2handler SAPI, the Thread Safe (TS) version of
    PHP must be used.
   </span>
  </p></blockquote>
  <p class="para">
   To load the PHP module for Apache 2.x, the following lines in the
   Apache <var class="filename">httpd.conf</var> configuration file must be inserted:
   <div class="example" id="example-1">
    <p><strong>Приклад #1 PHP and Apache 2.x as handler</strong></p>
    <div class="example-contents">
<div class="apache-confcode"><pre class="apache-confcode"># before PHP 8.0.0 the name of the module was php7_module
LoadModule php_module &quot;c:/php/php8apache2_4.dll&quot;
&lt;FilesMatch \.php$&gt;
    SetHandler application/x-httpd-php
&lt;/FilesMatch&gt;
# configure the path to php.ini
PHPIniDir &quot;C:/php&quot;</pre>
</div>
    </div>

   </div>
  </p>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <span class="simpara">
    The actual path to PHP must be substituted instead of
    <var class="filename">C:/php/</var> in the above examples.
    Make sure that the file referenced in the <code class="literal">LoadModule</code> directive is at
    the specified location. Use <var class="filename">php7apache2_4.dll</var>
    for PHP 7, or <var class="filename">php8apache2_4.dll</var> for PHP 8.
   </span>
  </p></blockquote>
 </div>

 <div class="sect2" id="install.windows.apache2.cgi">
  <h3 class="title">Running PHP as CGI</h3>

  <p class="para">
   It is strongly recommended to consult the
   <a href="http://httpd.apache.org/docs/current/howto/cgi.html" class="link external">&raquo;&nbsp;Apache CGI documentation</a>
   for a more complete understanding of running CGI on Apache.
  </p>

  <p class="para">
   To run PHP as CGI, the php-cgi files will need to be placed in a
   directory designated as a CGI directory using the ScriptAlias directive.
  </p>

  <p class="para">
   A <code class="literal">#!</code> line will need to be placed in the PHP files,
   which point to the location of the PHP binary:

   <div class="example" id="example-2">
    <p><strong>Приклад #2 PHP and Apache 2.x as CGI</strong></p>
    <div class="example-contents">
<div class="cdata"><pre>
#!C:/php/php.exe
&lt;?php
  phpinfo();
?&gt;
</pre></div>
    </div>

   </div>
  </p>
  <div class="warning"><strong class="warning">Увага</strong><p class="para">Використання сервера в
CGI-режимі робить його вразливим до деяких атак. В розділі <a href="security.cgi-bin.php" class="link">Безпека CGI</a> описано, як захиститися від
них.</p></div>
 </div>

 <div class="sect2" id="install.windows.apache2.fastcgi">
  <h3 class="title">Running PHP under FastCGI</h3>

  <p class="para">
   Running PHP under FastCGI has a number of advantages over running it as a
   CGI. Setting it up this way is fairly straightforward:
  </p>
  <p class="para">
   Obtain <code class="literal">mod_fcgid</code> from
   <a href="https://www.apachelounge.com/download/" class="link external">&raquo;&nbsp;https://www.apachelounge.com</a>.
   Win32 binaries are available for download from that site.
   Install the module according to the instructions that will come with it.
  </p>
  <p class="para">
   Configure the web server as shown below, taking care to adjust any paths
   to reflect how it is installed on the system:

   <div class="example" id="example-3">
    <p><strong>Приклад #3 Configure Apache to run PHP as FastCGI</strong></p>
    <div class="example-contents">
<div class="cdata"><pre>
LoadModule fcgid_module modules/mod_fcgid.so
# Where is the php.ini file?
FcgidInitialEnv PHPRC        &quot;c:/php&quot;
&lt;FilesMatch \.php$&gt;
    SetHandler fcgid-script
&lt;/FilesMatch&gt;
FcgidWrapper &quot;c:/php/php-cgi.exe&quot; .php
</pre></div>
    </div>

   </div>

   Files with a <code class="literal">.php</code> extension will now be executed by the PHP FastCGI
   wrapper.
  </p>
 </div>
</div><?php manual_footer($setup); ?>