Windows インストーラ (PHP 5.2 以降)
ActiveScript
Windows システムへのインストール
PHP Manual

## マニュアルインストール

This section contains instructions for manually installing and configuring PHP on Microsoft Windows. For the instructions on how to use PHP installer to setup and configure PHP and a web server on Windows refer to Windows Installer (PHP 5.2 and later).

### Selecting and downloading the PHP distribution package

Download the PHP zip binary distribution from » PHP for Windows: Binaries and Sources. There are several different versions of the zip package - chose the version that is suitable for the web server being used:

- If PHP is used with IIS then choose PHP 5.3 VC9 Non Thread Safe or PHP 5.2 VC6 Non Thread Safe;

- If PHP is used with Apache 1 or Apache 2 then choose PHP 5.3 VC6 or PHP 5.2 VC6.

> 注意: VC9 Versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability. The VC9 versions require you to have the » Microsoft 2008 C++ Runtime (x86) or the » Microsoft 2008 C++ Runtime (x64) installed.

### The PHP package structure and content

Unpack the content of the zip archive into a directory of your choice, for example C:\PHP\. The directory and file structure extracted from the zip will look as below:

例1 PHP 5 パッケージ構造

    c:\php
       |
       +--dev
       |  |
       |  |-php5ts.lib                 -- 非スレッドセーフバージョンの場合は php5.lib
       |
       +--ext                          -- PHP 拡張モジュールの DLL
       |  |
       |  |-php_bz2.dll
       |  |
       |  |-php_cpdf.dll
       |  |
       |  |-...
       |
       +--extras                       -- 空
       |
       +--pear                         -- PEAR の初期コピー
       |
       |
       |-go-pear.bat                   -- PEAR セットアップ用スクリプト
       |
       |-...
       |
       |-php-cgi.exe                   -- CGI 実行ファイル
       |
       |-php-win.exe                   -- コマンドプロンプトを開かずにスクリプトを実行する
       |
       |-php.exe                       -- コマンドラインの PHP 実行ファイル (CLI)
       |
       |-...
       |
       |-php.ini-development           -- デフォルトの php.ini 設定
       |
       |-php.ini-production            -- 推奨される php.ini 設定
       |
       |-php5apache2_2.dll             -- 非スレッドセーフバージョンには存在しません
       |
       |-php5apache2_2_filter.dll      -- 非スレッドセーフバージョンには存在しません
       |
       |-...
       |
       |-php5ts.dll                    -- コア PHP DLL ( 非スレッドセーフバージョンの場合は php5.dll )
       |
       |-...

Below is the list of the modules and executables included in the PHP zip distribution:

- go-pear.bat - the PEAR setup script. Refer to » Installation (PEAR) for more details.

- php-cgi.exe - CGI executable that can be used when running PHP on IIS via CGI or FastCGI.

- php-win.exe - the PHP executable for executing PHP scripts without using a command line window (for example PHP applications that use Windows GUI).

- php.exe - the PHP executable for executing PHP scripts within a command line interface (CLI).

- php5apache2_2.dll - Apache 2.2.X module.

- php5apache2_2_filter.dll - Apache 2.2.X filter.

### Changing the php.ini file

After the php package content has been extracted, copy the php.ini-production into php.ini in the same folder. If necessary, it is also possible to place the php.ini into any other location of your choice but that will require additional configuration steps as described in PHP Configuration.

The php.ini file tells PHP how to configure itself, and how to work with the environment that it runs in. Here are a number of settings for the php.ini file that help PHP work better with Windows. Some of these are optional. There are many other directives that may be relevant to your environment - refer to the list of php.ini directives for more information.

Required directives:

- extension_dir = <path to extension directory> - The extension_dir needs to point to the directory where PHP extensions files are stored. The path can be absolute (i.e. "C:\PHP\ext") or relative (i.e. ".\ext"). Extensions that are listed lower in the php.ini file need to be located in the extension_dir.

- extension = xxxxx.dll - For each extension you wish to enable, you need a corresponding "extension=" directive that tells PHP which extensions in the extension_dir to load at startup time.

- log_errors = On - PHP has an error logging facility that can be used to send errors to a file, or to a service (i.e. syslog) and works in conjunction with the error_log directive below. When running under IIS, the log_errors should be enabled, with a valid error_log.

- error_log = <path to the error log file> - The error_log needs to specify the absolute, or relative path to the file where PHP errors should be logged. This file needs to be writable for the web server. The most common places for this file are in various TEMP directories, for example "C:\inetpub\temp\php-errors.log".

- cgi.force_redirect = 0 - This directive is required for running under IIS. It is a directory security facility required by many other web servers. However, enabling it under IIS will cause the PHP engine to fail on Windows.

- cgi.fix_pathinfo = 1 - This lets PHP access real path info following the CGI Spec. The IIS FastCGI implementation needs this set.

- fastcgi.impersonate = 1 - FastCGI under IIS supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under.

- fastcgi.logging = 0 - FastCGI logging should be disabled on IIS. If it is left enabled, then any messages of any class are treated by FastCGI as error conditions which will cause IIS to generate an HTTP 500 exception.

Optional directives

- max_execution_time = ## - This directive tells PHP the maximum amount of time that it can spend executing any given script. The default for this is 30 seconds. Increase the value of this directive if PHP application take long time to execute.

- memory_limit = ###M - The amount of memory available for the PHP process, in Megabytes. The default is 128, which is fine for most PHP applications. Some of the more complex ones might need more.

- display_errors = Off - This directive tells PHP whether to include any error messages in the stream that it returns to the Web server. If this is set to "On", then PHP will send whichever classes of errors that you define with the error_reporting directive back to web server as part of the error stream. For security reasons it is recommended to set it to "Off" on production servers in order not to reveal any security sensitive information that is often included in the error messages.

- open_basedir = <paths to directories, separated by semicolon>, e.g. openbasedir="C:\inetpub\wwwroot;C:\inetpub\temp". This directive specified the directory paths where PHP is allowed to perform file system operations. Any file operation outside of the specified paths will result in an error. This directive is especially useful for locking down the PHP installation in shared hosting environments to prevent PHP scripts from accessing any files outside of the web site's root directory.

- upload_max_filesize = ###M and post_max_size = ###M - The maximum allowed size of an uploaded file and post data respectively. The values of these directives should be increased if PHP applications need to perform large uploads, such as for example photos or video files.

以上で、Windows への PHP のインストールが完了しました。ついで、 使用する WEB サーバ にあわせて、PHP を利用可能とするための設定を行います。 目次から使用する WEB サーバを選択し、該当するセクションを参照してください。

PHP をウェブサーバ経由で実行するだけでなく、 .BAT スクリプトなどでコマンドラインから実行することもできます。 詳細は Microsoft Windows コマンドラインでの PHP を参照ください。

Windows インストーラ (PHP 5.2 以降)
ActiveScript
Windows システムへのインストール
PHP Manual