home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / EasyPHP-2.0b1-setup.exe / {app} / php5 / install.txt < prev    next >
Encoding:
Text File  |  2006-11-02  |  89.3 KB  |  2,090 lines

  1. Installing PHP
  2.      _________________________________________________________________
  3.  
  4.    Table of Contents
  5.    Preface
  6.    1. General Installation Considerations
  7.    2. Installation on Windows systems
  8.  
  9.         Windows Installer
  10.         Manual Installation Steps
  11.         ActiveScript
  12.         Microsoft IIS / PWS
  13.         Apache 1.3.x on Microsoft Windows
  14.         Apache 2.0.x on Microsoft Windows
  15.         Sun, iPlanet and Netscape servers on Microsoft Windows
  16.         OmniHTTPd Server
  17.         Sambar Server on Microsoft Windows
  18.         Xitami on Microsoft Windows
  19.         Installation of extensions on Windows
  20.  
  21.    3. Installation of PECL extensions
  22.  
  23.         Introduction to PECL Installations
  24.         Downloading PECL extensions
  25.         PECL for Windows users
  26.         Compiling shared PECL extensions with PEAR
  27.         Compiling shared PECL extensions with phpize
  28.         Compiling PECL extensions statically into PHP
  29.  
  30.    4. Problems?
  31.  
  32.         Read the FAQ
  33.         Other problems
  34.         Bug reports
  35.  
  36.    5. Runtime Configuration
  37.  
  38.         The configuration file
  39.         How to change configuration settings
  40.  
  41.    6. Installation FAQ
  42.      _________________________________________________________________
  43.  
  44. Preface
  45.  
  46.    These installation instructions were generated from the HTML version
  47.    of the PHP Manual so formatting and linking have been altered. See the
  48.    online and updated version at: http://php.net/install.windows
  49.      _________________________________________________________________
  50.  
  51. Chapter 1. General Installation Considerations
  52.  
  53.    Before starting the installation, first you need to know what do you
  54.    want to use PHP for. There are three main fields you can use PHP, as
  55.    described in the What can PHP do? section:
  56.  
  57.      * Websites and web applications (server-side scripting)
  58.      * Command line scripting
  59.      * Desktop (GUI) applications
  60.  
  61.    For the first and most common form, you need three things: PHP itself,
  62.    a web server and a web browser. You probably already have a web
  63.    browser, and depending on your operating system setup, you may also
  64.    have a web server (e.g. Apache on Linux and MacOS X; IIS on Windows).
  65.    You may also rent webspace at a company. This way, you don't need to
  66.    set up anything on your own, only write your PHP scripts, upload it to
  67.    the server you rent, and see the results in your browser.
  68.  
  69.    In case of setting up the server and PHP on your own, you have two
  70.    choices for the method of connecting PHP to the server. For many
  71.    servers PHP has a direct module interface (also called SAPI). These
  72.    servers include Apache, Microsoft Internet Information Server,
  73.    Netscape and iPlanet servers. Many other servers have support for
  74.    ISAPI, the Microsoft module interface (OmniHTTPd for example). If PHP
  75.    has no module support for your web server, you can always use it as a
  76.    CGI or FastCGI processor. This means you set up your server to use the
  77.    CGI executable of PHP to process all PHP file requests on the server.
  78.  
  79.    If you are also interested to use PHP for command line scripting (e.g.
  80.    write scripts autogenerating some images for you offline, or
  81.    processing text files depending on some arguments you pass to them),
  82.    you always need the command line executable. For more information,
  83.    read the section about writing command line PHP applications. In this
  84.    case, you need no server and no browser.
  85.  
  86.    With PHP you can also write desktop GUI applications using the PHP-GTK
  87.    extension. This is a completely different approach than writing web
  88.    pages, as you do not output any HTML, but manage windows and objects
  89.    within them. For more information about PHP-GTK, please visit the site
  90.    dedicated to this extension. PHP-GTK is not included in the official
  91.    PHP distribution.
  92.  
  93.    From now on, this section deals with setting up PHP for web servers on
  94.    Unix and Windows with server module interfaces and CGI executables.
  95.    You will also find information on the command line executable in the
  96.    following sections.
  97.  
  98.    PHP source code and binary distributions for Windows can be found at
  99.    http://www.php.net/downloads.php. We recommend you to choose a mirror
  100.    nearest to you for downloading the distributions.
  101.      _________________________________________________________________
  102.  
  103. Chapter 2. Installation on Windows systems
  104.  
  105.    This section applies to Windows 98/Me and Windows NT/2000/XP/2003. PHP
  106.    will not work on 16 bit platforms such as Windows 3.1 and sometimes we
  107.    refer to the supported Windows platforms as Win32. Windows 95 is no
  108.    longer supported as of PHP 4.3.0.
  109.  
  110.    There are two main ways to install PHP for Windows: either manually or
  111.    by using the installer.
  112.  
  113.    If you have Microsoft Visual Studio, you can also build PHP from the
  114.    original source code.
  115.  
  116.    Once you have PHP installed on your Windows system, you may also want
  117.    to load various extensions for added functionality.
  118.  
  119.    Warning
  120.  
  121.    There are several all-in-one installers over the Internet, but none of
  122.    those are endorsed by PHP.net, as we believe that the manual
  123.    installation is the best choice to have your system secure and
  124.    optimised.
  125.      _________________________________________________________________
  126.  
  127. Windows Installer
  128.  
  129.    The Windows PHP installer is available from the downloads page at
  130.    http://www.php.net/downloads.php. This installs the CGI version of PHP
  131.    and for IIS, PWS, and Xitami, it configures the web server as well.
  132.    The installer does not include any extra external PHP extensions
  133.    (php_*.dll) as you'll only find those in the Windows Zip Package and
  134.    PECL downloads.
  135.  
  136.      Note: While the Windows installer is an easy way to make PHP work,
  137.      it is restricted in many aspects as, for example, the automatic
  138.      setup of extensions is not supported. Use of the installer isn't
  139.      the preferred method for installing PHP.
  140.  
  141.    First, install your selected HTTP (web) server on your system, and
  142.    make sure that it works.
  143.  
  144.    Run the executable installer and follow the instructions provided by
  145.    the installation wizard. Two types of installation are supported -
  146.    standard, which provides sensible defaults for all the settings it
  147.    can, and advanced, which asks questions as it goes along.
  148.  
  149.    The installation wizard gathers enough information to set up the
  150.    php.ini file, and configure certain web servers to use PHP. One of the
  151.    web servers the PHP installer does not configure for is Apache, so
  152.    you'll need to configure it manually.
  153.  
  154.    Once the installation has completed, the installer will inform you if
  155.    you need to restart your system, restart the server, or just start
  156.    using PHP.
  157.  
  158.    Warning
  159.  
  160.    Be aware, that this setup of PHP is not secure. If you would like to
  161.    have a secure PHP setup, you'd better go on the manual way, and set
  162.    every option carefully. This automatically working setup gives you an
  163.    instantly working PHP installation, but it is not meant to be used on
  164.    online servers.
  165.      _________________________________________________________________
  166.  
  167. Manual Installation Steps
  168.  
  169.    This install guide will help you manually install and configure PHP
  170.    with a web server on Microsoft Windows. To get started you'll need to
  171.    download the zip binary distribution from the downloads page at
  172.    http://www.php.net/downloads.php.
  173.  
  174.    Although there are many all-in-one installation kits, and we also
  175.    distribute a PHP installer for Microsoft Windows, we recommend you
  176.    take the time to setup PHP yourself as this will provide you with a
  177.    better understanding of the system, and enables you to install PHP
  178.    extensions easily when needed.
  179.  
  180.      Upgrading from a previous PHP version: Previous editions of the
  181.      manual suggest moving various ini and DLL files into your SYSTEM
  182.      (i.e. C:\WINDOWS) folder and while this simplifies the installation
  183.      procedure it makes upgrading difficult. We advise you remove all of
  184.      these files (like php.ini and PHP related DLLs from the Windows
  185.      SYSTEM folder) before moving on with a new PHP installation. Be
  186.      sure to backup these files as you might break the entire system.
  187.      The old php.ini might be useful in setting up the new PHP as well.
  188.      And as you'll soon learn, the preferred method for installing PHP
  189.      is to keep all PHP related files in one directory and have this
  190.      directory available to your systems PATH.
  191.  
  192.      MDAC requirements: If you use Microsoft Windows 98/NT4 download the
  193.      latest version of the Microsoft Data Access Components (MDAC) for
  194.      your platform. MDAC is available at
  195.      http://msdn.microsoft.com/data/. This requirement exists because
  196.      ODBC is built into the distributed Windows binaries.
  197.  
  198.    The following steps should be completed on all installations before
  199.    any server specific instructions are performed:
  200.  
  201.    Extract the distribution file into a directory of your choice. If you
  202.    are installing PHP 4, extract to C:\, as the zip file expands to a
  203.    foldername like php-4.3.7-Win32. If you are installing PHP 5, extract
  204.    to C:\php as the zip file doesn't expand as in PHP 4. You may choose a
  205.    different location but do not have spaces in the path (like C:\Program
  206.    Files\PHP) as some web servers will crash if you do.
  207.  
  208.    The directory structure extracted from the zip is different for PHP
  209.    versions 4 and 5 and look like as follows:
  210.  
  211.    Example 2-1. PHP 4 package structure
  212. c:\php
  213.    |
  214.    +--cli
  215.    |  |
  216.    |  |-php.exe           -- CLI executable - ONLY for commandline scripting
  217.    |
  218.    +--dlls                -- support DLLs required by some extensions
  219.    |  |
  220.    |  |-expat.dll
  221.    |  |
  222.    |  |-fdftk.dll
  223.    |  |
  224.    |  |-...
  225.    |
  226.    +--extensions          -- extension DLLs for PHP
  227.    |  |
  228.    |  |-php_bz2.dll
  229.    |  |
  230.    |  |-php_cpdf.dll
  231.    |  |
  232.    |  |-..
  233.    |
  234.    +--mibs                -- support files for SNMP
  235.    |
  236.    +--openssl             -- support files for Openssl
  237.    |
  238.    +--pdf-related         -- support files for PDF
  239.    |
  240.    +--sapi                -- SAPI (server module support) DLLs
  241.    |  |
  242.    |  |-php4apache.dll
  243.    |  |
  244.    |  |-php4apache2.dll
  245.    |  |
  246.    |  |-..
  247.    |
  248.    +--PEAR                -- initial copy of PEAR
  249.    |
  250.    |
  251.    |-go-pear.bat          -- PEAR setup script
  252.    |
  253.    |-..
  254.    |
  255.    |-php.exe              -- CGI executable
  256.    |
  257.    |-..
  258.    |
  259.    |-php.ini-dist         -- default php.ini settings
  260.    |
  261.    |-php.ini-recommended  -- recommended php.ini settings
  262.    |
  263.    |-php4ts.dll           -- core PHP DLL
  264.    |
  265.    |-...
  266.  
  267.    Or:
  268.  
  269.    Example 2-2. PHP 5 package structure
  270. c:\php
  271.    |
  272.    +--dev
  273.    |  |
  274.    |  |-php5ts.lib
  275.    |
  276.    +--ext                 -- extension DLLs for PHP
  277.    |  |
  278.    |  |-php_bz2.dll
  279.    |  |
  280.    |  |-php_cpdf.dll
  281.    |  |
  282.    |  |-..
  283.    |
  284.    +--extras
  285.    |  |
  286.    |  +--mibs             -- support files for SNMP
  287.    |  |
  288.    |  +--openssl          -- support files for Openssl
  289.    |  |
  290.    |  +--pdf-related      -- support files for PDF
  291.    |  |
  292.    |  |-mime.magic
  293.    |
  294.    +--pear                -- initial copy of PEAR
  295.    |
  296.    |
  297.    |-go-pear.bat          -- PEAR setup script
  298.    |
  299.    |-fdftk.dll
  300.    |
  301.    |-..
  302.    |
  303.    |-php-cgi.exe          -- CGI executable
  304.    |
  305.    |-php-win.exe          -- executes scripts without an opened command prompt
  306.    |
  307.    |-php.exe              -- CLI executable - ONLY for command line scripting
  308.    |
  309.    |-..
  310.    |
  311.    |-php.ini-dist         -- default php.ini settings
  312.    |
  313.    |-php.ini-recommended  -- recommended php.ini settings
  314.    |
  315.    |-php5activescript.dll
  316.    |
  317.    |-php5apache.dll
  318.    |
  319.    |-php5apache2.dll
  320.    |
  321.    |-..
  322.    |
  323.    |-php5ts.dll           -- core PHP DLL
  324.    |
  325.    |-...
  326.  
  327.    Notice the differences and similarities. Both PHP 4 and PHP 5 have a
  328.    CGI executable, a CLI executable, and server modules, but they are
  329.    located in different folders and/or have different names. While PHP 4
  330.    packages have the server modules in the sapi folder, PHP 5
  331.    distributions have no such directory and instead they're in the PHP
  332.    folder root. The supporting DLLs for the PHP 5 extensions are also not
  333.    in a seperate directory.
  334.  
  335.      Note: In PHP 4, you should move all files located in the dll and
  336.      sapi folders to the main folder (e.g. C:\php).
  337.  
  338.    Here is a list of server modules shipped with PHP 4 and PHP 5:
  339.  
  340.      * sapi/php4activescript.dll (php5activescript.dll) - ActiveScript
  341.        engine, allowing you to embed PHP in your Windows applications.
  342.      * sapi/php4apache.dll (php5apache.dll) - Apache 1.3.x module.
  343.      * sapi/php4apache2.dll (php5apache2.dll) - Apache 2.0.x module.
  344.      * sapi/php4isapi.dll (php5isapi.dll) - ISAPI Module for ISAPI
  345.        compliant web servers like IIS 4.0/PWS 4.0 or newer.
  346.      * sapi/php4nsapi.dll (php5nsapi.dll) - Sun/iPlanet/Netscape server
  347.        module.
  348.      * sapi/php4pi3web.dll (no equivalent in PHP 5) - Pi3Web server
  349.        module.
  350.  
  351.    Server modules provide significantly better performance and additional
  352.    functionality compared to the CGI binary. The CLI version is designed
  353.    to let you use PHP for command line scripting. More information about
  354.    CLI is available in the chapter about using PHP from the command line.
  355.  
  356.    Warning
  357.  
  358.    The SAPI modules have been significantly improved as of the 4.1
  359.    release, however, in older systems you may encounter server errors or
  360.    other server modules failing, such as ASP.
  361.  
  362.    The CGI and CLI binaries, and the web server modules all require the
  363.    php4ts.dll (php5ts.dll) file to be available to them. You have to make
  364.    sure that this file can be found by your PHP installation. The search
  365.    order for this DLL is as follows:
  366.  
  367.      * The same directory from where php.exe is called, or in case you
  368.        use a SAPI module, the web server's directory (e.g. C:\Program
  369.        Files\Apache Group\Apache2\bin).
  370.      * Any directory in your Windows PATH environment variable.
  371.  
  372.    To make php4ts.dll / php5ts.dll available you have three options: copy
  373.    the file to the Windows system directory, copy the file to the web
  374.    server's directory, or add your PHP directory, C:\php to the PATH. For
  375.    better maintenance, we advise you to follow the last option, add
  376.    C:\php to the PATH, because it will be simpler to upgrade PHP in the
  377.    future. Read more about how to add your PHP directory to PATH in the
  378.    corresponding FAQ entry (and then don't forget to restart the computer
  379.    - logoff isn't enough).
  380.  
  381.    The next step is to set up a valid configuration file for PHP,
  382.    php.ini. There are two ini files distributed in the zip file,
  383.    php.ini-dist and php.ini-recommended. We advise you to use
  384.    php.ini-recommended, because we optimized the default settings in this
  385.    file for performance, and security. Read this well documented file
  386.    carefully because it has changes from php.ini-dist that will
  387.    drastically affect your setup. Some examples are display_errors being
  388.    off and magic_quotes_gpc being off. In addition to reading these,
  389.    study the ini settings and set every element manually yourself. If you
  390.    would like to achieve the best security, then this is the way for you,
  391.    although PHP works fine with these default ini files. Copy your chosen
  392.    ini-file to a directory that PHP is able to find and rename it to
  393.    php.ini. PHP searches for php.ini in the locations described in the
  394.    Section called The configuration file in Chapter 5 section.
  395.  
  396.    If you are running Apache 2, the simpler option is to use the
  397.    PHPIniDir directive (read the installation on Apache 2 page),
  398.    otherwise your best option is to set the PHPRC environment variable.
  399.    This process is explained in the following FAQ entry.
  400.  
  401.      Note: If you're using NTFS on Windows NT, 2000, XP or 2003, make
  402.      sure that the user running the web server has read permissions to
  403.      your php.ini (e.g. make it readable by Everyone).
  404.  
  405.    The following steps are optional:
  406.  
  407.      * Edit your new php.ini file. If you plan to use OmniHTTPd, do not
  408.        follow the next step. Set the doc_root to point to your web
  409.        servers document_root. For example:
  410.  
  411. doc_root = c:\inetpub\wwwroot // for IIS/PWS
  412.  
  413. doc_root = c:\apache\htdocs // for Apache
  414.  
  415.      * Choose the extensions you would like to load when PHP starts. See
  416.        the section about Windows extensions, about how to set up one, and
  417.        what is already built in. Note that on a new installation it is
  418.        advisable to first get PHP working and tested without any
  419.        extensions before enabling them in php.ini.
  420.      * On PWS and IIS, you can set the browscap configuration setting to
  421.        point to: c:\windows\system\inetsrv\browscap.ini on Windows 9x/Me,
  422.        c:\winnt\system32\inetsrv\browscap.ini on NT/2000, and
  423.        c:\windows\system32\inetsrv\browscap.ini on XP. For an up-to-date
  424.        browscap.ini, read the following FAQ.
  425.  
  426.    PHP is now setup on your system. The next step is to choose a web
  427.    server, and enable it to run PHP. Choose a webserver from the table of
  428.    contents.
  429.      _________________________________________________________________
  430.  
  431. ActiveScript
  432.  
  433.    This section contains notes specific to the ActiveScript installation.
  434.  
  435.    ActiveScript is a windows only SAPI that enables you to use PHP script
  436.    in any ActiveScript compliant host, like Windows Script Host,
  437.    ASP/ASP.NET, Windows Script Components or Microsoft Scriptlet control.
  438.  
  439.    As of PHP 5.0.1, ActiveScript has been moved to the PECL repository.
  440.    You may download this PECL extension DLL from the PHP Downloads page
  441.    or at http://snaps.php.net/.
  442.  
  443.      Note: You should read the manual installation steps first!
  444.  
  445.    After installing PHP, you should download the ActiveScript DLL
  446.    (php5activescript.dll) and place it in the main PHP folder (e.g.
  447.    C:\php).
  448.  
  449.    After having all the files needed, you must register the DLL on your
  450.    system. To achieve this, open a Command Prompt window (located in the
  451.    Start Menu). Then go to your PHP directory by typing something like cd
  452.    C:\php. To register the DLL just type regsvr32 php5activescript.dll.
  453.  
  454.    To test if ActiveScript is working, create a new file, named test.wsf
  455.    (the extension is very important) and type:
  456. <job id="test">
  457.  
  458.  <script language="PHPScript">
  459.   $WScript->Echo("Hello World!");
  460.  </script>
  461.  
  462. </job>
  463.  
  464.    Save and double-click on the file. If you receive a little window
  465.    saying "Hello World!" you're done.
  466.  
  467.      Note: In PHP 4, the engine was named 'ActivePHP', so if you are
  468.      using PHP 4, you should replace 'PHPScript' with 'ActivePHP' in the
  469.      above example.
  470.  
  471.      Note: ActiveScript doesn't use the default php.ini file. Instead,
  472.      it will look only in the same directory as the .exe that caused it
  473.      to load. You should create php-activescript.ini and place it in
  474.      that folder, if you wish to load extensions, etc.
  475.      _________________________________________________________________
  476.  
  477. Microsoft IIS / PWS
  478.  
  479.    This section contains notes and hints specific to IIS (Microsoft
  480.    Internet Information Server).
  481.  
  482.    Warning
  483.  
  484.    By using the CGI setup, your server is open to several possible
  485.    attacks. Please read our CGI security section to learn how to defend
  486.    yourself from those attacks.
  487.      _________________________________________________________________
  488.  
  489. General considerations for all installations of PHP with IIS or PWS
  490.  
  491.      * First, read the Manual Installation Instructions. Do not skip this
  492.        step as it provides crucial information for installing PHP on
  493.        Windows.
  494.      * CGI users must set the cgi.force_redirect PHP directive to 0
  495.        inside php.ini. Read the faq on cgi.force_redirect for important
  496.        details. Also, CGI users may want to set the
  497.        cgi.redirect_status_env directive. When using directives, be sure
  498.        these directives aren't commented out inside php.ini.
  499.      * The PHP 4 CGI is named php.exe while in PHP 5 it's php-cgi.exe. In
  500.        PHP 5, php.exe is the CLI, and not the CGI.
  501.      * Modify the Windows PATH environment variable to include the PHP
  502.        directory. This way the PHP DLL files, PHP executables, and
  503.        php.ini can all remain in the PHP directory without cluttering up
  504.        the Windows system directory. For more details, see the FAQ on
  505.        Setting the PATH.
  506.      * The IIS user (usually IUSR_MACHINENAME) needs permission to read
  507.        various files and directories, such as php.ini, docroot, and the
  508.        session tmp directory.
  509.      * Be sure the extension_dir and doc_root PHP directives are
  510.        appropriately set in php.ini. These directives depend on the
  511.        system that PHP is being installed on. In PHP 4, the extension_dir
  512.        is extensions while with PHP 5 it's ext. So, an example PHP 5
  513.        extensions_dir value is "c:\php\ext" and an example IIS doc_root
  514.        value is "c:\Inetpub\wwwroot".
  515.      * PHP extension DLL files, such as php_mysql.dll and php_curl.dll,
  516.        are found in the zip package of the PHP download (not the PHP
  517.        installer). In PHP 5, many extensions are part of PECL and can be
  518.        downloaded in the "Collection of PECL modules" package. Files such
  519.        as php_zip.dll and php_ssh2.dll. Download PHP files here.
  520.      * When defining the executable, the 'check that file exists' box may
  521.        also be checked. For a small performance penalty, the IIS (or PWS)
  522.        will check that the script file exists and sort out authentication
  523.        before firing up PHP. This means that the web server will provide
  524.        sensible 404 style error messages instead of CGI errors
  525.        complaining that PHP did not output any data.
  526.      _________________________________________________________________
  527.  
  528. Windows NT/200x/XP and IIS 4 or newer
  529.  
  530.    PHP may be installed as a CGI binary, or with the ISAPI module. In
  531.    either case, you need to start the Microsoft Management Console (may
  532.    appear as 'Internet Services Manager', either in your Windows NT 4.0
  533.    Option Pack branch or the Control Panel=>Administrative Tools under
  534.    Windows 2000/XP). Then right click on your Web server node (this will
  535.    most probably appear as 'Default Web Server'), and select
  536.    'Properties'.
  537.  
  538.    If you want to use the CGI binary, do the following:
  539.  
  540.      * Under 'Home Directory', 'Virtual Directory', or 'Directory', do
  541.        the following:
  542.      * Change the Execute Permissions to 'Scripts only'
  543.      * Click on the 'Configuration' button, and choose the Application
  544.        Mappings tab. Click Add and set the Executable path to the
  545.        appropriate CGI file. An example PHP 5 value is:
  546.        C:\php\php-cgi.exe Supply .php as the extension. Leave 'Method
  547.        exclusions' blank, and check the 'Script engine' checkbox. Now,
  548.        click OK a few times.
  549.      * Set up the appropriate security. (This is done in Internet Service
  550.        Manager), and if your NT Server uses NTFS file system, add execute
  551.        rights for I_USR_ to the directory that contains php.exe /
  552.        php-cgi.exe.
  553.  
  554.    To use the ISAPI module, do the following:
  555.  
  556.      * If you don't want to perform HTTP Authentication using PHP, you
  557.        can (and should) skip this step. Under ISAPI Filters, add a new
  558.        ISAPI filter. Use PHP as the filter name, and supply a path to the
  559.        php4isapi.dll / php5isapi.dll.
  560.      * Under 'Home Directory', 'Virtual Directory', or 'Directory', do
  561.        the following:
  562.      * Change the Execute Permissions to 'Scripts only'
  563.      * Click on the 'Configuration' button, and choose the Application
  564.        Mappings tab. Click Add and set the Executable path to the
  565.        appropriate ISAPI DLL. An example PHP 5 value is:
  566.        C:\php\php5isapi.dll Supply .php as the extension. Leave 'Method
  567.        exclusions' blank, and check the 'Script engine' checkbox. Now,
  568.        click OK a few times.
  569.      * Stop IIS completely (NET STOP iisadmin)
  570.      * Start IIS again (NET START w3svc)
  571.  
  572.    With IIS 6 (2003 Server), open up the IIS Manager, go to Web Service
  573.    Extensions, choose "Add a new Web service extension", enter in a name
  574.    such as PHP, choose the Add button and for the value browse to either
  575.    the ISAPI file (php4isapi.dll or php5isapi.dll) or CGI (php.exe or
  576.    php-cgi.exe) then check "Set extension status to Allowed" and click
  577.    OK.
  578.  
  579.    In order to use index.php as a default content page, do the following:
  580.    From within the Documents tab, choose Add. Type in index.php and click
  581.    OK. Adjust the order by choosing Move Up or Move Down. This is similar
  582.    to setting DirectoryIndex with Apache.
  583.  
  584.    The steps above must be repeated for each extension that is to be
  585.    associated with PHP scripts. .php is the most common although .php3
  586.    may be required for legacy applications.
  587.  
  588.    If you experience 100% CPU usage after some time, turn off the IIS
  589.    setting Cache ISAPI Application.
  590.      _________________________________________________________________
  591.  
  592. Windows and PWS 4
  593.  
  594.    PWS 4 does not support ISAPI, only PHP CGI should be used.
  595.  
  596.      * Edit the enclosed pws-php4cgi.reg / pws-php5cgi.reg file (look
  597.        into the SAPI folder for PHP 4, or in the main folder for PHP 5)
  598.        to reflect the location of your php.exe / php-cgi.exe. Backslashes
  599.        should be escaped, for example:
  600.        [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parame
  601.        ters\Script Map] ".php"="C:\\php\\php.exe" (change to
  602.        C:\\php\\php-cgi.exe if you are using PHP 5) Now merge this
  603.        registery file into your system; you may do this by
  604.        double-clicking it.
  605.      * In the PWS Manager, right click on a given directory you want to
  606.        add PHP support to, and select Properties. Check the 'Execute'
  607.        checkbox, and confirm.
  608.      _________________________________________________________________
  609.  
  610. Windows and PWS/IIS 3
  611.  
  612.    The recommended method for configuring these servers is to use the REG
  613.    file included with the distribution (pws-php4cgi.reg in the SAPI
  614.    folder for PHP 4, or pws-php5cgi.reg in the main folder for PHP 5).
  615.    You may want to edit this file and make sure the extensions and PHP
  616.    install directories match your configuration. Or you can follow the
  617.    steps below to do it manually.
  618.  
  619.    Warning
  620.  
  621.    These steps involve working directly with the Windows registry. One
  622.    error here can leave your system in an unstable state. We highly
  623.    recommend that you back up your registry first. The PHP Development
  624.    team will not be held responsible if you damage your registry.
  625.  
  626.      * Run Regedit.
  627.      * Navigate to: HKEY_LOCAL_MACHINE /System /CurrentControlSet
  628.        /Services /W3Svc /Parameters /ScriptMap.
  629.      * On the edit menu select: New->String Value.
  630.      * Type in the extension you wish to use for your php scripts. For
  631.        example .php
  632.      * Double click on the new string value and enter the path to php.exe
  633.        in the value data field. ex: C:\php\php.exe "%s" %s for PHP 4, or
  634.        C:\php\php-cgi.exe "%s" %s for PHP 5.
  635.      * Repeat these steps for each extension you wish to associate with
  636.        PHP scripts.
  637.  
  638.    The following steps do not affect the web server installation and only
  639.    apply if you want your PHP scripts to be executed when they are run
  640.    from the command line (ex. run C:\myscripts\test.php) or by double
  641.    clicking on them in a directory viewer window. You may wish to skip
  642.    these steps as you might prefer the PHP files to load into a text
  643.    editor when you double click on them.
  644.  
  645.      * Navigate to: HKEY_CLASSES_ROOT
  646.      * On the edit menu select: New->Key.
  647.      * Name the key to the extension you setup in the previous section.
  648.        ex: .php
  649.      * Highlight the new key and in the right side pane, double click the
  650.        "default value" and enter phpfile.
  651.      * Repeat the last step for each extension you set up in the previous
  652.        section.
  653.      * Now create another New->Key under HKEY_CLASSES_ROOT and name it
  654.        phpfile.
  655.      * Highlight the new key phpfile and in the right side pane, double
  656.        click the "default value" and enter PHP Script.
  657.      * Right click on the phpfile key and select New->Key, name it Shell.
  658.      * Right click on the Shell key and select New->Key, name it open.
  659.      * Right click on the open key and select New->Key, name it command.
  660.      * Highlight the new key command and in the right side pane, double
  661.        click the "default value" and enter the path to php.exe. ex:
  662.        c:\php\php.exe -q %1. (don't forget the %1).
  663.      * Exit Regedit.
  664.      * If using PWS on Windows, reboot to reload the registry.
  665.  
  666.    PWS and IIS 3 users now have a fully operational system. IIS 3 users
  667.    can use a nifty tool from Steven Genusa to configure their script
  668.    maps.
  669.      _________________________________________________________________
  670.  
  671. Apache 1.3.x on Microsoft Windows
  672.  
  673.    This section contains notes and hints specific to Apache 1.3.x
  674.    installs of PHP on Microsoft Windows systems. There are also
  675.    instructions and notes for Apache 2 on a separate page.
  676.  
  677.      Note: Please read the manual installation steps first!
  678.  
  679.    There are two ways to set up PHP to work with Apache 1.3.x on Windows.
  680.    One is to use the CGI binary (php.exe for PHP 4 and php-cgi.exe for
  681.    PHP 5), the other is to use the Apache Module DLL. In either case you
  682.    need to edit your httpd.conf to configure Apache to work with PHP, and
  683.    then restart the server.
  684.  
  685.    It is worth noting here that now the SAPI module has been made more
  686.    stable under Windows, we recommend it's use above the CGI binary,
  687.    since it is more transparent and secure.
  688.  
  689.    Although there can be a few variations of configuring PHP under
  690.    Apache, these are simple enough to be used by the newcomer. Please
  691.    consult the Apache Documentation for further configuration directives.
  692.  
  693.    After changing the configuration file, remember to restart the server,
  694.    for example, NET STOP APACHE followed by NET START APACHE, if you run
  695.    Apache as a Windows Service, or use your regular shortcuts.
  696.  
  697.      Note: Remember that when adding path values in the Apache
  698.      configuration files on Windows, all backslashes such as
  699.      c:\directory\file.ext must be converted to forward slashes, as
  700.      c:/directory/file.ext. A trailing slash may also be necessary for
  701.      directories.
  702.      _________________________________________________________________
  703.  
  704. Installing as an Apache module
  705.  
  706.    You should add the following lines to your Apache httpd.conf file:
  707.  
  708.    Example 2-3. PHP as an Apache 1.3.x module
  709.  
  710.    This assumes PHP is installed to c:\php. Adjust the path if this is
  711.    not the case.
  712.  
  713.    For PHP 4:
  714. # Add to the end of the LoadModule section
  715. # Don't forget to copy this file from the sapi directory!
  716. LoadModule php4_module "C:/php/php4apache.dll"
  717.  
  718. # Add to the end of the AddModule section
  719. AddModule mod_php4.c
  720.  
  721.    For PHP 5:
  722. # Add to the end of the LoadModule section
  723. LoadModule php5_module "C:/php/php5apache.dll"
  724.  
  725. # Add to the end of the AddModule section
  726. AddModule mod_php5.c
  727.  
  728.    For both:
  729. # Add this line inside the <IfModule mod_mime.c> conditional brace
  730. AddType application/x-httpd-php .php
  731.  
  732. # For syntax highlighted .phps files, also add
  733. AddType application/x-httpd-php-source .phps
  734.      _________________________________________________________________
  735.  
  736. Installing as a CGI binary
  737.  
  738.    If you unzipped the PHP package to C:\php\ as described in the Manual
  739.    Installation Steps section, you need to insert these lines to your
  740.    Apache configuration file to set up the CGI binary:
  741.  
  742.    Example 2-4. PHP and Apache 1.3.x as CGI
  743. ScriptAlias /php/ "c:/php/"
  744. AddType application/x-httpd-php .php
  745.  
  746. # For PHP 4
  747. Action application/x-httpd-php "/php/php.exe"
  748.  
  749. # For PHP 5
  750. Action application/x-httpd-php "/php/php-cgi.exe"
  751.  
  752. # specify the directory where php.ini is
  753. SetEnv PHPRC C:/php
  754.  
  755.    Note that the second line in the list above can be found in the actual
  756.    versions of httpd.conf, but it is commented out. Remember also to
  757.    substitute the c:/php/ for your actual path to PHP.
  758.  
  759.    Warning
  760.  
  761.    By using the CGI setup, your server is open to several possible
  762.    attacks. Please read our CGI security section to learn how to defend
  763.    yourself from those attacks.
  764.  
  765.    If you would like to present PHP source files syntax highlighted,
  766.    there is no such convenient option as with the module version of PHP.
  767.    If you chose to configure Apache to use PHP as a CGI binary, you will
  768.    need to use the highlight_file() function. To do this simply create a
  769.    PHP script file and add this code: <?php
  770.    highlight_file('some_php_script.php'); ?>.
  771.      _________________________________________________________________
  772.  
  773. Apache 2.0.x on Microsoft Windows
  774.  
  775.    This section contains notes and hints specific to Apache 2.0.x
  776.    installs of PHP on Microsoft Windows systems. We also have
  777.    instructions and notes for Apache 1.3.x users on a separate page.
  778.  
  779.      Note: You should read the manual installation steps first!
  780.  
  781.      Apache 2.2.x Support: Users of Apache 2.2.x may use the
  782.      documentation below except the appropriate DLL file is named
  783.      php5apache2_2.dll and it only exists as of PHP 5.2.0. See also
  784.      http://snaps.php.net/
  785.  
  786.    Warning
  787.  
  788.    We do not recommend using a threaded MPM in production with Apache2.
  789.    Use the prefork MPM instead, or use Apache1. For information on why,
  790.    read the related FAQ entry on using Apache2 with a threaded MPM
  791.  
  792.    You are highly encouraged to take a look at the Apache Documentation
  793.    to get a basic understanding of the Apache 2.0.x Server. Also consider
  794.    to read the Windows specific notes for Apache 2.0.x before reading on
  795.    here.
  796.  
  797.      PHP and Apache 2.0.x compatibility notes: The following versions of
  798.      PHP are known to work with the most recent version of Apache 2.0.x:
  799.  
  800.      * PHP 4.3.0 or later available at http://www.php.net/downloads.php.
  801.      * the latest stable development version. Get the source code
  802.        http://snaps.php.net/php5-latest.tar.gz or download binaries for
  803.        Windows http://snaps.php.net/win32/php5-win32-latest.zip.
  804.      * a prerelease version downloadable from http://qa.php.net/.
  805.      * you have always the option to obtain PHP through anonymous CVS.
  806.  
  807.      These versions of PHP are compatible to Apache 2.0.40 and later.
  808.  
  809.      Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works
  810.      with Apache 2.0.39, don't use any other version of Apache with PHP
  811.      4.2.3. However, the recommended setup is to use PHP 4.3.0 or later
  812.      with the most recent version of Apache2.
  813.  
  814.      All mentioned versions of PHP will work still with Apache 1.3.x.
  815.  
  816.    Warning
  817.  
  818.    Apache 2.0.x is designed to run on Windows NT 4.0, Windows 2000 or
  819.    Windows XP. At this time, support for Windows 9x is incomplete. Apache
  820.    2.0.x is not expected to work on those platforms at this time.
  821.  
  822.    Download the most recent version of Apache 2.0.x and a fitting PHP
  823.    version. Follow the Manual Installation Steps and come back to go on
  824.    with the integration of PHP and Apache.
  825.  
  826.    There are two ways to set up PHP to work with Apache 2.0.x on Windows.
  827.    One is to use the CGI binary the other is to use the Apache module
  828.    DLL. In either case you need to edit your httpd.conf to configure
  829.    Apache to work with PHP and then restart the server.
  830.  
  831.      Note: Remember that when adding path values in the Apache
  832.      configuration files on Windows, all backslashes such as
  833.      c:\directory\file.ext must be converted to forward slashes, as
  834.      c:/directory/file.ext. A trailing slash may also be necessary for
  835.      directories.
  836.      _________________________________________________________________
  837.  
  838. Installing as a CGI binary
  839.  
  840.    You need to insert these three lines to your Apache httpd.conf
  841.    configuration file to set up the CGI binary:
  842.  
  843.    Example 2-5. PHP and Apache 2.0 as CGI
  844. ScriptAlias /php/ "c:/php/"
  845. AddType application/x-httpd-php .php
  846.  
  847. # For PHP 4
  848. Action application/x-httpd-php "/php/php.exe"
  849.  
  850. # For PHP 5
  851. Action application/x-httpd-php "/php/php-cgi.exe"
  852.  
  853.    Warning
  854.  
  855.    By using the CGI setup, your server is open to several possible
  856.    attacks. Please read our CGI security section to learn how to defend
  857.    yourself from those attacks.
  858.      _________________________________________________________________
  859.  
  860. Installing as an Apache module
  861.  
  862.    You need to insert these two lines to your Apache httpd.conf
  863.    configuration file to set up the PHP module for Apache 2.0:
  864.  
  865.    Example 2-6. PHP and Apache 2.0 as Module
  866. # For PHP 4 do something like this:
  867. LoadModule php4_module "c:/php/php4apache2.dll"
  868. # Don't forget to copy the php4apache2.dll file from the sapi directory!
  869. AddType application/x-httpd-php .php
  870.  
  871. # For PHP 5 do something like this:
  872. LoadModule php5_module "c:/php/php5apache2.dll"
  873. AddType application/x-httpd-php .php
  874.  
  875. # configure the path to php.ini
  876. PHPIniDir "C:/php"
  877.  
  878.      Note: Remember to substitute your actual path to PHP for the
  879.      c:/php/ in the above examples. Take care to use either
  880.      php4apache2.dll or php5apache2.dll in your LoadModule directive and
  881.      not php4apache.dll or php5apache.dll as the latter ones are
  882.      designed to run with Apache 1.3.x.
  883.  
  884.      Note: If you want to use content negotiation, read related FAQ.
  885.  
  886.    Warning
  887.  
  888.    Don't mix up your installation with DLL files from different PHP
  889.    versions. You have the only choice to use the DLL's and extensions
  890.    that ship with your downloaded PHP version.
  891.      _________________________________________________________________
  892.  
  893. Sun, iPlanet and Netscape servers on Microsoft Windows
  894.  
  895.    This section contains notes and hints specific to Sun Java System Web
  896.    Server, Sun ONE Web Server, iPlanet and Netscape server installs of
  897.    PHP on Windows.
  898.  
  899.    From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to
  900.    generate custom directory listings and error pages. Additional
  901.    functions for Apache compatibility are also available. For support in
  902.    current webservers read the note about subrequests.
  903.      _________________________________________________________________
  904.  
  905. CGI setup on Sun, iPlanet and Netscape servers
  906.  
  907.    To install PHP as a CGI handler, do the following:
  908.  
  909.      * Copy php4ts.dll to your systemroot (the directory where you
  910.        installed Windows)
  911.      * Make a file association from the command line. Type the following
  912.        two lines:
  913.  
  914. assoc .php=PHPScript
  915. ftype PHPScript=c:\php\php.exe %1 %*
  916.  
  917.      * In the Netscape Enterprise Administration Server create a dummy
  918.        shellcgi directory and remove it just after (this step creates 5
  919.        important lines in obj.conf and allow the web server to handle
  920.        shellcgi scripts).
  921.      * In the Netscape Enterprise Administration Server create a new mime
  922.        type (Category: type, Content-Type: magnus-internal/shellcgi, File
  923.        Suffix:php).
  924.      * Do it for each web server instance you want PHP to run
  925.  
  926.    More details about setting up PHP as a CGI executable can be found
  927.    here: http://benoit.noss.free.fr/php/install-php.html
  928.      _________________________________________________________________
  929.  
  930. NSAPI setup on Sun, iPlanet and Netscape servers
  931.  
  932.    To install PHP with NSAPI, do the following:
  933.  
  934.      * Copy php4ts.dll to your systemroot (the directory where you
  935.        installed Windows)
  936.      * Make a file association from the command line. Type the following
  937.        two lines:
  938.  
  939. assoc .php=PHPScript
  940. ftype PHPScript=c:\php\php.exe %1 %*
  941.  
  942.      * In the Netscape Enterprise Administration Server create a new mime
  943.        type (Category: type, Content-Type: magnus-internal/x-httpd-php,
  944.        File Suffix: php).
  945.      * Edit magnus.conf (for servers >= 6) or obj.conf (for servers < 6)
  946.        and add the following: You should place the lines after mime types
  947.        init.
  948.  
  949. Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c:
  950. /php/sapi/php4nsapi.dll"
  951. Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP!" [php
  952. _ini="c:/path/to/php.ini"]
  953.  
  954.        (PHP >= 4.3.3) The php_ini parameter is optional but with it you
  955.        can place your php.ini in your webserver config directory.
  956.      * Configure the default object in obj.conf (for virtual server
  957.        classes [Sun Web Server 6.0+] in their vserver.obj.conf): In the
  958.        <Object name="default"> section, place this line necessarily after
  959.        all 'ObjectType' and before all 'AddLog' lines:
  960.  
  961. Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inik
  962. ey=value ...]
  963.  
  964.        (PHP >= 4.3.3) As additional parameters you can add some special
  965.        php.ini-values, for example you can set a
  966.        docroot="/path/to/docroot" specific to the context php4_execute is
  967.        called. For boolean ini-keys please use 0/1 as value, not
  968.        "On","Off",... (this will not work correctly), e.g.
  969.        zlib.output_compression=1 instead of zlib.output_compression="On"
  970.      * This is only needed if you want to configure a directory that only
  971.        consists of PHP scripts (same like a cgi-bin directory):
  972.  
  973. <Object name="x-httpd-php">
  974. ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
  975. Service fn=php4_execute [inikey=value inikey=value ...]
  976. </Object>
  977.  
  978.        After that you can configure a directory in the Administration
  979.        server and assign it the style x-httpd-php. All files in it will
  980.        get executed as PHP. This is nice to hide PHP usage by renaming
  981.        files to .html.
  982.      * Restart your web service and apply changes
  983.      * Do it for each web server instance you want PHP to run
  984.  
  985.      Note: More details about setting up PHP as an NSAPI filter can be
  986.      found here: http://benoit.noss.free.fr/php/install-php4.html
  987.  
  988.      Note: The stacksize that PHP uses depends on the configuration of
  989.      the webserver. If you get crashes with very large PHP scripts, it
  990.      is recommended to raise it with the Admin Server (in the section
  991.      "MAGNUS EDITOR").
  992.      _________________________________________________________________
  993.  
  994. CGI environment and recommended modifications in php.ini
  995.  
  996.    Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
  997.    WS/iPlanet/Netscape is a multithreaded web server. Because of that all
  998.    requests are running in the same process space (the space of the
  999.    webserver itself) and this space has only one environment. If you want
  1000.    to get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the
  1001.    correct way to try this in the old PHP 3.x way with getenv() or a
  1002.    similar way (register globals to environment, $_ENV). You would only
  1003.    get the environment of the running webserver without any valid CGI
  1004.    variables!
  1005.  
  1006.      Note: Why are there (invalid) CGI variables in the environment?
  1007.  
  1008.      Answer: This is because you started the webserver process from the
  1009.      admin server which runs the startup script of the webserver, you
  1010.      wanted to start, as a CGI script (a CGI script inside of the admin
  1011.      server!). This is why the environment of the started webserver has
  1012.      some CGI environment variables in it. You can test this by starting
  1013.      the webserver not from the administration server. Use the command
  1014.      line as root user and start it manually - you will see there are no
  1015.      CGI-like environment variables.
  1016.  
  1017.    Simply change your scripts to get CGI variables in the correct way for
  1018.    PHP 4.x by using the superglobal $_SERVER. If you have older scripts
  1019.    which use $HTTP_HOST, etc., you should turn on register_globals in
  1020.    php.ini and change the variable order too (important: remove "E" from
  1021.    it, because you do not need the environment here):
  1022. variables_order = "GPCS"
  1023. register_globals = On
  1024.      _________________________________________________________________
  1025.  
  1026. Special use for error pages or self-made directory listings (PHP >= 4.3.3)
  1027.  
  1028.    You can use PHP to generate the error pages for "404 Not Found" or
  1029.    similar. Add the following line to the object in obj.conf for every
  1030.    error page you want to overwrite:
  1031. Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value ini
  1032. key=value...]
  1033.  
  1034.    where XXX is the HTTP error code. Please delete any other Error
  1035.    directives which could interfere with yours. If you want to place a
  1036.    page for all errors that could exist, leave the code parameter out.
  1037.    Your script can get the HTTP status code with $_SERVER['ERROR_TYPE'].
  1038.  
  1039.    Another possibility is to generate self-made directory listings. Just
  1040.    create a PHP script which displays a directory listing and replace the
  1041.    corresponding default Service line for
  1042.    type="magnus-internal/directory" in obj.conf with the following:
  1043. Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/scr
  1044. ipt.php" [inikey=value inikey=value...]
  1045.  
  1046.    For both error and directory listing pages the original URI and
  1047.    translated URI are in the variables $_SERVER['PATH_INFO'] and
  1048.    $_SERVER['PATH_TRANSLATED'].
  1049.      _________________________________________________________________
  1050.  
  1051. Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)
  1052.  
  1053.    The NSAPI module now supports the nsapi_virtual() function (alias:
  1054.    virtual()) to make subrequests on the webserver and insert the result
  1055.    in the webpage. The problem is, that this function uses some
  1056.    undocumented features from the NSAPI library.
  1057.  
  1058.    Under Unix this is not a problem, because the module automatically
  1059.    looks for the needed functions and uses them if available. If not,
  1060.    nsapi_virtual() is disabled.
  1061.  
  1062.    Under Windows limitations in the DLL handling need the use of a
  1063.    automatic detection of the most recent ns-httpdXX.dll file. This is
  1064.    tested for servers till version 6.1. If a newer version of the Sun
  1065.    server is used, the detection fails and nsapi_virtual() is disabled.
  1066.  
  1067.    If this is the case, try the following: Add the following parameter to
  1068.    php4_init in magnus.conf/obj.conf:
  1069.    Init fn=php4_init ... server_lib="ns-httpdXX.dll"
  1070.  
  1071.    where XX is the correct DLL version number. To get it, look in the
  1072.    server-root for the correct DLL name. The DLL with the biggest
  1073.    filesize is the right one.
  1074.  
  1075.    You can check the status by using the phpinfo() function.
  1076.  
  1077.      Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!
  1078.      _________________________________________________________________
  1079.  
  1080. OmniHTTPd Server
  1081.  
  1082.    This section contains notes and hints specific to OmniHTTPd on
  1083.    Windows.
  1084.  
  1085.      Note: You should read the manual installation steps first!
  1086.  
  1087.    Warning
  1088.  
  1089.    By using the CGI setup, your server is open to several possible
  1090.    attacks. Please read our CGI security section to learn how to defend
  1091.    yourself from those attacks.
  1092.  
  1093.    You need to complete the following steps to make PHP work with
  1094.    OmniHTTPd. This is a CGI executable setup. SAPI is supported by
  1095.    OmniHTTPd, but some tests have shown that it is not so stable to use
  1096.    PHP as an ISAPI module.
  1097.  
  1098.      Important for CGI users: Read the faq on cgi.force_redirect for
  1099.      important details. This directive needs to be set to 0.
  1100.  
  1101.     1. Install OmniHTTPd server.
  1102.     2. Right click on the blue OmniHTTPd icon in the system tray and
  1103.        select Properties
  1104.     3. Click on Web Server Global Settings
  1105.     4. On the 'External' tab, enter: virtual = .php | actual =
  1106.        c:\php\php.exe (use php-cgi.exe if installing PHP 5), and use the
  1107.        Add button.
  1108.     5. On the Mime tab, enter: virtual = wwwserver/stdcgi | actual =
  1109.        .php, and use the Add button.
  1110.     6. Click OK
  1111.  
  1112.    Repeat steps 2 - 6 for each extension you want to associate with PHP.
  1113.  
  1114.      Note: Some OmniHTTPd packages come with built in PHP support. You
  1115.      can choose at setup time to do a custom setup, and uncheck the PHP
  1116.      component. We recommend you to use the latest PHP binaries. Some
  1117.      OmniHTTPd servers come with PHP 4 beta distributions, so you should
  1118.      choose not to set up the built in support, but install your own. If
  1119.      the server is already on your machine, use the Replace button in
  1120.      Step 4 and 5 to set the new, correct information.
  1121.      _________________________________________________________________
  1122.  
  1123. Sambar Server on Microsoft Windows
  1124.  
  1125.    This section contains notes and hints specific to the Sambar Server
  1126.    for Windows.
  1127.  
  1128.      Note: You should read the manual installation steps first!
  1129.  
  1130.    This list describes how to set up the ISAPI module to work with the
  1131.    Sambar server on Windows.
  1132.  
  1133.      * Find the file called mappings.ini (in the config directory) in the
  1134.        Sambar install directory.
  1135.      * Open mappings.ini and add the following line under [ISAPI]:
  1136.  
  1137.    Example 2-7. ISAPI configuration of Sambar
  1138. #for PHP 4
  1139. *.php = c:\php\php4isapi.dll
  1140.  
  1141. #for PHP 5
  1142. *.php = c:\php\php5isapi.dll
  1143.  
  1144.        (This line assumes that PHP was installed in c:\php.)
  1145.      * Now restart the Sambar server for the changes to take effect.
  1146.      _________________________________________________________________
  1147.  
  1148. Xitami on Microsoft Windows
  1149.  
  1150.    This section contains notes and hints specific to Xitami on Windows.
  1151.  
  1152.      Note: You should read the manual installation steps first!
  1153.  
  1154.    This list describes how to set up the PHP CGI binary to work with
  1155.    Xitami on Windows.
  1156.  
  1157.      Important for CGI users: Read the faq on cgi.force_redirect for
  1158.      important details. This directive needs to be set to 0. If you want
  1159.      to use $_SERVER['PHP_SELF'] you have to enable the cgi.fix_pathinfo
  1160.      directive.
  1161.  
  1162.    Warning
  1163.  
  1164.    By using the CGI setup, your server is open to several possible
  1165.    attacks. Please read our CGI security section to learn how to defend
  1166.    yourself from those attacks.
  1167.  
  1168.      * Make sure the webserver is running, and point your browser to
  1169.        xitamis admin console (usually http://127.0.0.1/admin), and click
  1170.        on Configuration.
  1171.      * Navigate to the Filters, and put the extension which PHP should
  1172.        parse (i.e. .php) into the field File extensions (.xxx).
  1173.      * In Filter command or script put the path and name of your PHP CGI
  1174.        executable i.e. C:\php\php.exe for PHP 4, or C:\php\php-cgi.exe
  1175.        for PHP 5.
  1176.      * Press the 'Save' icon.
  1177.      * Restart the server to reflect changes.
  1178.      _________________________________________________________________
  1179.  
  1180. Installation of extensions on Windows
  1181.  
  1182.    After installing PHP and a webserver on Windows, you will probably
  1183.    want to install some extensions for added functionality. You can
  1184.    choose which extensions you would like to load when PHP starts by
  1185.    modifying your php.ini. You can also load a module dynamically in your
  1186.    script using dl().
  1187.  
  1188.    The DLLs for PHP extensions are prefixed with php_.
  1189.  
  1190.    Many extensions are built into the Windows version of PHP. This means
  1191.    additional DLL files, and the extension directive, are not used to
  1192.    load these extensions. The Windows PHP Extensions table lists
  1193.    extensions that require, or used to require, additional PHP DLL files.
  1194.    Here's a list of built in extensions:
  1195.  
  1196.    In PHP 4 (updated PHP 4.3.11): BCMath, Caledar, COM, Ctype, FTP,
  1197.    MySQL, ODBC, Overload, PCRE, Session, Tokenizer, WDDX, XML and Zlib
  1198.  
  1199.    In PHP 5 (updated PHP 5.0.4), the following changes exist. Built in:
  1200.    DOM, LibXML, Iconv, SimpleXML, SPL and SQLite. And the following are
  1201.    no longer built in: MySQL and Overload.
  1202.  
  1203.    The default location PHP searches for extensions is C:\php4\extensions
  1204.    in PHP 4 and C:\php5 in PHP 5. To change this setting to reflect your
  1205.    setup of PHP edit your php.ini file:
  1206.  
  1207.      * You will need to change the extension_dir setting to point to the
  1208.        directory where your extensions lives, or where you have placed
  1209.        your php_*.dll files. For example:
  1210.  
  1211. extension_dir = C:\php\extensions
  1212.  
  1213.      * Enable the extension(s) in php.ini you want to use by uncommenting
  1214.        the extension=php_*.dll lines in php.ini. This is done by deleting
  1215.        the leading ; from the extension you want to load.
  1216.  
  1217.    Example 2-8. Enable Bzip2 extension for PHP-Windows
  1218. // change the following line from ...
  1219. ;extension=php_bz2.dll
  1220.  
  1221. // ... to
  1222. extension=php_bz2.dll
  1223.  
  1224.      * Some of the extensions need extra DLLs to work. Couple of them can
  1225.        be found in the distribution package, in the C:\php\dlls\ folder
  1226.        in PHP 4 or in the main folder in PHP 5, but some, for example
  1227.        Oracle (php_oci8.dll) require DLLs which are not bundled with the
  1228.        distribution package. If you are installing PHP 4, copy the
  1229.        bundled DLLs from C:\php\dlls folder to the main C:\php folder.
  1230.        Don't forget to include C:\php in the system PATH (this process is
  1231.        explained in a separate FAQ entry).
  1232.      * Some of these DLLs are not bundled with the PHP distribution. See
  1233.        each extensions documentation page for details. Also, read the
  1234.        manual section titled Installation of PECL extensions for details
  1235.        on PECL. An increasingly large number of PHP extensions are found
  1236.        in PECL, and these extensions require a separate download.
  1237.  
  1238.      Note: If you are running a server module version of PHP remember to
  1239.      restart your webserver to reflect your changes to php.ini.
  1240.  
  1241.    The following table describes some of the extensions available and
  1242.    required additional dlls.
  1243.  
  1244.    Table 2-1. PHP Extensions
  1245.    Extension Description Notes
  1246.    php_bz2.dll bzip2 compression functions None
  1247.    php_calendar.dll Calendar conversion functions Built in since PHP
  1248.    4.0.3
  1249.    php_cpdf.dll ClibPDF functions None
  1250.    php_crack.dll Crack functions None
  1251.    php_ctype.dll ctype family functions Built in since PHP 4.3.0
  1252.    php_curl.dll CURL, Client URL library functions Requires:
  1253.    libeay32.dll, ssleay32.dll (bundled)
  1254.    php_cybercash.dll Cybercash payment functions PHP <= 4.2.0
  1255.    php_db.dll DBM functions Deprecated. Use DBA instead (php_dba.dll)
  1256.    php_dba.dll DBA: DataBase (dbm-style) Abstraction layer functions None
  1257.    php_dbase.dll dBase functions None
  1258.    php_dbx.dll dbx functions
  1259.    php_domxml.dll DOM XML functions PHP <= 4.2.0 requires: libxml2.dll
  1260.    (bundled) PHP >= 4.3.0 requires: iconv.dll (bundled)
  1261.    php_dotnet.dll .NET functions PHP <= 4.1.1
  1262.    php_exif.dll EXIF functions php_mbstring.dll. And, php_exif.dll must
  1263.    be loaded after php_mbstring.dll in php.ini.
  1264.    php_fbsql.dll FrontBase functions PHP <= 4.2.0
  1265.    php_fdf.dll FDF: Forms Data Format functions. Requires: fdftk.dll
  1266.    (bundled)
  1267.    php_filepro.dll filePro functions Read-only access
  1268.    php_ftp.dll FTP functions Built-in since PHP 4.0.3
  1269.    php_gd.dll GD library image functions Removed in PHP 4.3.2. Also note
  1270.    that truecolor functions are not available in GD1, instead, use
  1271.    php_gd2.dll.
  1272.    php_gd2.dll GD library image functions GD2
  1273.    php_gettext.dll Gettext functions PHP <= 4.2.0 requires
  1274.    gnu_gettext.dll (bundled), PHP >= 4.2.3 requires libintl-1.dll,
  1275.    iconv.dll (bundled).
  1276.    php_hyperwave.dll HyperWave functions None
  1277.    php_iconv.dll ICONV characterset conversion Requires: iconv-1.3.dll
  1278.    (bundled), PHP >=4.2.1 iconv.dll
  1279.    php_ifx.dll Informix functions Requires: Informix libraries
  1280.    php_iisfunc.dll IIS management functions None
  1281.    php_imap.dll IMAP POP3 and NNTP functions None
  1282.    php_ingres.dll Ingres II functions Requires: Ingres II libraries
  1283.    php_interbase.dll InterBase functions Requires: gds32.dll (bundled)
  1284.    php_java.dll Java functions PHP <= 4.0.6 requires: jvm.dll (bundled)
  1285.    php_ldap.dll LDAP functions PHP <= 4.2.0 requires libsasl.dll
  1286.    (bundled), PHP >= 4.3.0 requires libeay32.dll, ssleay32.dll (bundled)
  1287.    php_mbstring.dll Multi-Byte String functions None
  1288.    php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll
  1289.    php_mhash.dll Mhash functions PHP >= 4.3.0 requires: libmhash.dll
  1290.    (bundled)
  1291.    php_mime_magic.dll Mimetype functions Requires: magic.mime (bundled)
  1292.    php_ming.dll Ming functions for Flash None
  1293.    php_msql.dll mSQL functions Requires: msql.dll (bundled)
  1294.    php_mssql.dll MSSQL functions Requires: ntwdblib.dll (bundled)
  1295.    php_mysql.dll MySQL functions PHP >= 5.0.0, requires libmysql.dll
  1296.    (bundled)
  1297.    php_mysqli.dll MySQLi functions PHP >= 5.0.0, requires libmysql.dll
  1298.    (libmysqli.dll in PHP <= 5.0.2) (bundled)
  1299.    php_oci8.dll Oracle 8 functions Requires: Oracle 8.1+ client libraries
  1300.    php_openssl.dll OpenSSL functions Requires: libeay32.dll (bundled)
  1301.    php_oracle.dll Oracle functions Requires: Oracle 7 client libraries
  1302.    php_overload.dll Object overloading functions Built in since PHP 4.3.0
  1303.    php_pdf.dll PDF functions None
  1304.    php_pgsql.dll PostgreSQL functions None
  1305.    php_printer.dll Printer functions None
  1306.    php_shmop.dll Shared Memory functions None
  1307.    php_snmp.dll SNMP get and walk functions NT only!
  1308.    php_soap.dll SOAP functions PHP >= 5.0.0
  1309.    php_sockets.dll Socket functions None
  1310.    php_sybase_ct.dll Sybase functions Requires: Sybase client libraries
  1311.    php_tidy.dll Tidy functions PHP >= 5.0.0
  1312.    php_tokenizer.dll Tokenizer functions Built in since PHP 4.3.0
  1313.    php_w32api.dll W32api functions None
  1314.    php_xmlrpc.dll XML-RPC functions PHP >= 4.2.1 requires: iconv.dll
  1315.    (bundled)
  1316.    php_xslt.dll XSLT functions PHP <= 4.2.0 requires sablot.dll,
  1317.    expat.dll (bundled). PHP >= 4.2.1 requires sablot.dll, expat.dll,
  1318.    iconv.dll (bundled).
  1319.    php_yaz.dll YAZ functions Requires: yaz.dll (bundled)
  1320.    php_zip.dll Zip File functions Read only access
  1321.    php_zlib.dll ZLib compression functions Built in since PHP 4.3.0
  1322.      _________________________________________________________________
  1323.  
  1324. Chapter 3. Installation of PECL extensions
  1325.  
  1326. Introduction to PECL Installations
  1327.  
  1328.    PECL is a repository of PHP extensions that are made available to you
  1329.    via the PEAR packaging system. This section of the manual is intended
  1330.    to demonstrate how to obtain and install PECL extensions.
  1331.  
  1332.    These instructions assume /your/phpsrcdir/ is the path to the PHP
  1333.    source distribution, and that extname is the name of the PECL
  1334.    extension. Adjust accordingly. These instructions also assume a
  1335.    familiarity with the pear command.
  1336.  
  1337.    To be useful, a shared extension must be built, installed, and loaded.
  1338.    The methods described below provide you with various instructions on
  1339.    how to build and install the extensions, but they do not automatically
  1340.    load them. Extensions can be loaded by adding an extension directive.
  1341.    To this php.ini file, or through the use of the dl() function.
  1342.  
  1343.    When building PHP modules, it's important to have known-good versions
  1344.    of the required tools (autoconf, automake, libtool, etc.) See the
  1345.    Anonymous CVS Instructions for details on the required tools, and
  1346.    required versions.
  1347.      _________________________________________________________________
  1348.  
  1349. Downloading PECL extensions
  1350.  
  1351.    There are several options for downloading PECL extensions, such as:
  1352.  
  1353.      * http://pecl.php.net
  1354.        The PECL web site contains information about the different
  1355.        extensions that are offered by the PHP Development Team. The
  1356.        information available here includes: ChangeLog, release notes,
  1357.        requirements and other similar details.
  1358.      * pear download extname
  1359.        PECL extensions that have releases listed on the PECL web site are
  1360.        available for download and installation using the pear command.
  1361.        Specific revisions may also be specified.
  1362.      * CVS
  1363.        Most PECL extensions also reside in CVS. A web-based view may be
  1364.        seen at http://cvs.php.net/pecl/. To download straight from CVS,
  1365.        the following sequence of commands may be used. Note that phpfi is
  1366.        the password for user cvsread:
  1367.  
  1368. $ cvs -d:pserver:cvsread@cvs.php.net:/repository login
  1369. $ cvs -d:pserver:cvsread@cvs.php.net:/repository co pecl/extname
  1370.  
  1371.      * Windows downloads
  1372.        Windows users may find compiled PECL binaries by downloading the
  1373.        Collection of PECL modules from the PHP Downloads page, and by
  1374.        retrieving a PECL Snapshot. To compile PHP under Windows, read the
  1375.        appropriate chapter.
  1376.      _________________________________________________________________
  1377.  
  1378. PECL for Windows users
  1379.  
  1380.    As with any other PHP extension DLL, installation is as simple as
  1381.    copying the PECL extension DLLs into the extension_dir folder and
  1382.    loading them from php.ini. For example, add the following line to your
  1383.    php.ini:
  1384.  
  1385.    extension=php_extname.dll
  1386.  
  1387.    After doing this, restart the web server.
  1388.      _________________________________________________________________
  1389.  
  1390. Compiling shared PECL extensions with PEAR
  1391.  
  1392.    PEAR makes it easy to create shared PHP extensions. Using the pear
  1393.    command, do the following:
  1394.  
  1395.    $ pear install extname
  1396.  
  1397.    This will download the source for extname, compile, and install
  1398.    extname.so into your extension_dir. extname.so may then be loaded via
  1399.    php.ini
  1400.  
  1401.    By default, the pear command will not install packages that are marked
  1402.    with the alpha or beta state. If no stable packages are available, you
  1403.    may install a beta package using the following command:
  1404.  
  1405.    $ pear install extname-beta
  1406.  
  1407.    You may also install a specific version using this variant:
  1408.  
  1409.    $ pear install extname-0.1
  1410.      _________________________________________________________________
  1411.  
  1412. Compiling shared PECL extensions with phpize
  1413.  
  1414.    Sometimes, using the pear installer is not an option. This could be
  1415.    because you're behind a firewall, or it could be because the extension
  1416.    you want to install is not available as a PEAR compatible package,
  1417.    such as unreleased extensions from CVS. If you need to build such an
  1418.    extension, you can use the lower-level build tools to perform the
  1419.    build manually.
  1420.  
  1421.    The phpize command is used to prepare the build environment for a PHP
  1422.    extension. In the following sample, the sources for an extension are
  1423.    in a directory named extname:
  1424.  
  1425. $ cd extname
  1426. $ phpize
  1427. $ ./configure
  1428. $ make
  1429. # make install
  1430.  
  1431.    A successful install will have created extname.so and put it into the
  1432.    PHP extensions directory. You'll need to and adjust php.ini and add an
  1433.    extension=extname.so line before you can use the extension.
  1434.  
  1435.    If the system is missing the phpize command, and precompiled packages
  1436.    (like RPM's) are used, be sure to also install the appropriate devel
  1437.    version of the PHP package as they often include the phpize command
  1438.    along with the appropriate header files to build PHP and its
  1439.    extensions.
  1440.  
  1441.    Execute phpize --help to display additional usage information.
  1442.      _________________________________________________________________
  1443.  
  1444. Compiling PECL extensions statically into PHP
  1445.  
  1446.    You might find that you need to build a PECL extension statically into
  1447.    your PHP binary. To do this, you'll need to place the extension source
  1448.    under the php-src/ext/ directory and tell the PHP build system to
  1449.    regenerate its configure script.
  1450.  
  1451. $ cd /your/phpsrcdir/ext
  1452. $ pear download extname
  1453. $ gzip -d < extname.tgz | tar -xvf -
  1454. $ mv extname-x.x.x extname
  1455.  
  1456.    This will result in the following directory:
  1457.  
  1458.    /your/phpsrcdir/ext/extname
  1459.  
  1460.    From here, force PHP to rebuild the configure script, and then build
  1461.    PHP as normal:
  1462.  
  1463. $ cd /your/phpsrcdir
  1464. $ rm configure
  1465. $ ./buildconf --force
  1466. $ ./configure --help
  1467. $ ./configure --with-extname --enable-someotherext --with-foobar
  1468. $ make
  1469. $ make install
  1470.  
  1471.      Note: To run the 'buildconf' script you need autoconf 2.13 and
  1472.      automake 1.4+ (newer versions of autoconf may work, but are not
  1473.      supported).
  1474.  
  1475.    Whether --enable-extname or --with-extname is used depends on the
  1476.    extension. Typically an extension that does not require external
  1477.    libraries uses --enable. To be sure, run the following after
  1478.    buildconf:
  1479.  
  1480.    $ ./configure --help | grep extname
  1481.      _________________________________________________________________
  1482.  
  1483. Chapter 4. Problems?
  1484.  
  1485. Read the FAQ
  1486.  
  1487.    Some problems are more common than others. The most common ones are
  1488.    listed in the PHP FAQ, part of this manual.
  1489.      _________________________________________________________________
  1490.  
  1491. Other problems
  1492.  
  1493.    If you are still stuck, someone on the PHP installation mailing list
  1494.    may be able to help you. You should check out the archive first, in
  1495.    case someone already answered someone else who had the same problem as
  1496.    you. The archives are available from the support page on
  1497.    http://www.php.net/support.php. To subscribe to the PHP installation
  1498.    mailing list, send an empty mail to
  1499.    php-install-subscribe@lists.php.net. The mailing list address is
  1500.    php-install@lists.php.net.
  1501.  
  1502.    If you want to get help on the mailing list, please try to be precise
  1503.    and give the necessary details about your environment (which operating
  1504.    system, what PHP version, what web server, if you are running PHP as
  1505.    CGI or a server module, safe mode, etc...), and preferably enough code
  1506.    to make others able to reproduce and test your problem.
  1507.      _________________________________________________________________
  1508.  
  1509. Bug reports
  1510.  
  1511.    If you think you have found a bug in PHP, please report it. The PHP
  1512.    developers probably don't know about it, and unless you report it,
  1513.    chances are it won't be fixed. You can report bugs using the
  1514.    bug-tracking system at http://bugs.php.net/. Please do not send bug
  1515.    reports in mailing list or personal letters. The bug system is also
  1516.    suitable to submit feature requests.
  1517.  
  1518.    Read the How to report a bug document before submitting any bug
  1519.    reports!
  1520.      _________________________________________________________________
  1521.  
  1522. Chapter 5. Runtime Configuration
  1523.  
  1524. The configuration file
  1525.  
  1526.    The configuration file (called php3.ini in PHP 3, and simply php.ini
  1527.    as of PHP 4) is read when PHP starts up. For the server module
  1528.    versions of PHP, this happens only once when the web server is
  1529.    started. For the CGI and CLI version, it happens on every invocation.
  1530.  
  1531.    php.ini is searched in these locations (in order):
  1532.  
  1533.      * SAPI module specific location (PHPIniDir directive in Apache 2, -c
  1534.        command line option in CGI and CLI, php_ini parameter in NSAPI,
  1535.        PHP_INI_PATH environment variable in THTTPD)
  1536.      * The PHPRC environment variable. Before PHP 5.2.0 this was checked
  1537.        after the registry key mentioned below.
  1538.      * HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry
  1539.        location)
  1540.      * Current working directory (for CLI)
  1541.      * The web server's directory (for SAPI modules), or directory of PHP
  1542.        (otherwise in Windows)
  1543.      * Windows directory (C:\windows or C:\winnt) (for Windows), or
  1544.        --with-config-file-path compile time option
  1545.  
  1546.    If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is
  1547.    e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini.
  1548.    SAPI name can be determined by php_sapi_name().
  1549.  
  1550.      Note: The Apache web server changes the directory to root at
  1551.      startup causing PHP to attempt to read php.ini from the root
  1552.      filesystem if it exists.
  1553.  
  1554.    The php.ini directives handled by extensions are documented
  1555.    respectively on the pages of the extensions themselves. The list of
  1556.    the core directives is available in the appendix. Probably not all PHP
  1557.    directives are documented in the manual though. For a complete list of
  1558.    directives available in your PHP version, please read your well
  1559.    commented php.ini file. Alternatively, you may find the the latest
  1560.    php.ini from CVS helpful too.
  1561.  
  1562.    Example 5-1. php.ini example
  1563. ; any text on a line after an unquoted semicolon (;) is ignored
  1564. [php] ; section markers (text within square brackets) are also ignored
  1565. ; Boolean values can be set to either:
  1566. ;    true, on, yes
  1567. ; or false, off, no, none
  1568. register_globals = off
  1569. track_errors = yes
  1570.  
  1571. ; you can enclose strings in double-quotes
  1572. include_path = ".:/usr/local/lib/php"
  1573.  
  1574. ; backslashes are treated the same as any other character
  1575. include_path = ".;c:\php\lib"
  1576.  
  1577.    Since PHP 5.1.0, it is possible to refer to existing .ini variables
  1578.    from within .ini files. Example: open_basedir = ${open_basedir}
  1579.    ":/new/dir".
  1580.      _________________________________________________________________
  1581.  
  1582. How to change configuration settings
  1583.  
  1584. Running PHP as an Apache module
  1585.  
  1586.    When using PHP as an Apache module, you can also change the
  1587.    configuration settings using directives in Apache configuration files
  1588.    (e.g. httpd.conf) and .htaccess files. You will need "AllowOverride
  1589.    Options" or "AllowOverride All" privileges to do so.
  1590.  
  1591.    With PHP 4 and PHP 5, there are several Apache directives that allow
  1592.    you to change the PHP configuration from within the Apache
  1593.    configuration files. For a listing of which directives are
  1594.    PHP_INI_ALL, PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the
  1595.    List of php.ini directives appendix.
  1596.  
  1597.      Note: With PHP 3, there are Apache directives that correspond to
  1598.      each configuration setting in the php3.ini name, except the name is
  1599.      prefixed by "php3_".
  1600.  
  1601.    php_value name value
  1602.           Sets the value of the specified directive. Can be used only
  1603.           with PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a
  1604.           previously set value use none as the value.
  1605.  
  1606.      Note: Don't use php_value to set boolean values. php_flag (see
  1607.      below) should be used instead.
  1608.  
  1609.    php_flag name on|off
  1610.           Used to set a boolean configuration directive. Can be used only
  1611.           with PHP_INI_ALL and PHP_INI_PERDIR type directives.
  1612.  
  1613.    php_admin_value name value
  1614.           Sets the value of the specified directive. This can not be used
  1615.           in .htaccess files. Any directive type set with php_admin_value
  1616.           can not be overridden by .htaccess or virtualhost directives.
  1617.           To clear a previously set value use none as the value.
  1618.  
  1619.    php_admin_flag name on|off
  1620.           Used to set a boolean configuration directive. This can not be
  1621.           used in .htaccess files. Any directive type set with
  1622.           php_admin_flag can not be overridden by .htaccess or
  1623.           virtualhost directives.
  1624.  
  1625.    Example 5-2. Apache configuration example
  1626. <IfModule mod_php5.c>
  1627.   php_value include_path ".:/usr/local/lib/php"
  1628.   php_admin_flag safe_mode on
  1629. </IfModule>
  1630. <IfModule mod_php4.c>
  1631.   php_value include_path ".:/usr/local/lib/php"
  1632.   php_admin_flag safe_mode on
  1633. </IfModule>
  1634. <IfModule mod_php3.c>
  1635.   php3_include_path ".:/usr/local/lib/php"
  1636.   php3_safe_mode on
  1637. </IfModule>
  1638.  
  1639.    Caution
  1640.  
  1641.    PHP constants do not exist outside of PHP. For example, in httpd.conf
  1642.    you can not use PHP constants such as E_ALL or E_NOTICE to set the
  1643.    error_reporting directive as they will have no meaning and will
  1644.    evaluate to 0. Use the associated bitmask values instead. These
  1645.    constants can be used in php.ini
  1646.      _________________________________________________________________
  1647.  
  1648. Changing PHP configuration via the Windows registry
  1649.  
  1650.    When running PHP on Windows, the configuration values can be modified
  1651.    on a per-directory basis using the Windows registry. The configuration
  1652.    values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory
  1653.    Values, in the sub-keys corresponding to the path names. For example,
  1654.    configuration values for the directory c:\inetpub\wwwroot would be
  1655.    stored in the key HKLM\SOFTWARE\PHP\Per Directory
  1656.    Values\c\inetpub\wwwroot. The settings for the directory would be
  1657.    active for any script running from this directory or any subdirectory
  1658.    of it. The values under the key should have the name of the PHP
  1659.    configuration directive and the string value. PHP constants in the
  1660.    values are not parsed. However, only configuration values changeable
  1661.    in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not.
  1662.      _________________________________________________________________
  1663.  
  1664. Other interfaces to PHP
  1665.  
  1666.    Regardless of how you run PHP, you can change certain values at
  1667.    runtime of your scripts through ini_set(). See the documentation on
  1668.    the ini_set() page for more information.
  1669.  
  1670.    If you are interested in a complete list of configuration settings on
  1671.    your system with their current values, you can execute the phpinfo()
  1672.    function, and review the resulting page. You can also access the
  1673.    values of individual configuration directives at runtime using
  1674.    ini_get() or get_cfg_var().
  1675.      _________________________________________________________________
  1676.  
  1677. Chapter 6. Installation FAQ
  1678.  
  1679.    This section holds common questions about the way to install PHP. PHP
  1680.    is available for almost any OS (except maybe for MacOS before OSX),
  1681.    and almost any web server.
  1682.  
  1683.    To install PHP, follow the instructions in Installing PHP.
  1684.  
  1685.    1. Why shouldn't I use Apache2 with a threaded MPM in a production
  1686.           environment?
  1687.  
  1688.    2. Unix/Windows: Where should my php.ini file be located?
  1689.    3. Unix: I installed PHP, but every time I load a document, I get the
  1690.           message 'Document Contains No Data'! What's going on here?
  1691.  
  1692.    4. Unix: I installed PHP using RPMS, but Apache isn't processing the
  1693.           PHP pages! What's going on here?
  1694.  
  1695.    5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the
  1696.           database support I need! What's going on here?
  1697.  
  1698.    6. Unix: I patched Apache with the FrontPage extensions patch, and
  1699.           suddenly PHP stopped working. Is PHP incompatible with the
  1700.           Apache FrontPage extensions?
  1701.  
  1702.    7. Unix/Windows: I have installed PHP, but when I try to access a PHP
  1703.           script file via my browser, I get a blank screen.
  1704.  
  1705.    8. Unix/Windows: I have installed PHP, but when try to access a PHP
  1706.           script file via my browser, I get a server 500 error.
  1707.  
  1708.    9. Some operating systems: I have installed PHP without errors, but
  1709.           when I try to start apache I get undefined symbol errors:
  1710.  
  1711. [mybox:user /src/php4] root# apachectl configtest
  1712.  apachectl: /usr/local/apache/bin/httpd Undefined symbols:
  1713.   _compress
  1714.   _uncompress
  1715.  
  1716.    10. Windows: I have installed PHP, but when I to access a PHP script
  1717.           file via my browser, I get the error:
  1718.  
  1719. cgi error:
  1720.  The specified CGI application misbehaved by not
  1721.  returning a complete set of HTTP headers.
  1722.  The headers it did return are:
  1723.  
  1724.    11. Windows: I've followed all the instructions, but still can't get
  1725.           PHP and IIS to work together!
  1726.  
  1727.    12. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get
  1728.           the following error: Security Alert! PHP CGI cannot be accessed
  1729.           directly..
  1730.  
  1731.    13. How do I know if my php.ini is being found and read? It seems like
  1732.           it isn't as my changes aren't being implemented.
  1733.  
  1734.    14. How do I add my PHP directory to the PATH on Windows?
  1735.    15. How do I make the php.ini file available to PHP on windows?
  1736.    16. Is it possible to use Apache content negotiation (MultiViews
  1737.           option) with PHP?
  1738.  
  1739.    17. Is PHP limited to process GET and POST request methods only?
  1740.  
  1741.    1. Why shouldn't I use Apache2 with a threaded MPM in a production
  1742.    environment?
  1743.  
  1744.    PHP is glue. It is the glue used to build cool web applications by
  1745.    sticking dozens of 3rd-party libraries together and making it all
  1746.    appear as one coherent entity through an intuitive and easy to learn
  1747.    language interface. The flexibility and power of PHP relies on the
  1748.    stability and robustness of the underlying platform. It needs a
  1749.    working OS, a working web server and working 3rd-party libraries to
  1750.    glue together. When any of these stop working PHP needs ways to
  1751.    identify the problems and fix them quickly. When you make the
  1752.    underlying framework more complex by not having completely separate
  1753.    execution threads, completely separate memory segments and a strong
  1754.    sandbox for each request to play in, feet of clay are introduced into
  1755.    PHP's system.
  1756.  
  1757.    If you feel you have to use a threaded MPM, look at a FastCGI
  1758.    configuration where PHP is running in its own memory space.
  1759.  
  1760.    And finally, this warning against using a threaded MPM is not as
  1761.    strong for Windows systems because most libraries on that platform
  1762.    tend to be threadsafe.
  1763.  
  1764.    2. Unix/Windows: Where should my php.ini file be located?
  1765.  
  1766.    By default on Unix it should be in /usr/local/lib which is
  1767.    <install-path>/lib. Most people will want to change this at
  1768.    compile-time with the --with-config-file-path flag. You would, for
  1769.    example, set it with something like:
  1770.    --with-config-file-path=/etc
  1771.  
  1772.    And then you would copy php.ini-dist from the distribution to
  1773.    /etc/php.ini and edit it to make any local changes you want.
  1774.    --with-config-file-scan-dir=PATH
  1775.  
  1776.    On Windows the default path for the php.ini file is the Windows
  1777.    directory. If you're using the Apache webserver, php.ini is first
  1778.    searched in the Apaches install directory, e.g. c:\program
  1779.    files\apache group\apache. This way you can have different php.ini
  1780.    files for different versions of Apache on the same machine.
  1781.  
  1782.    See also the chapter about the configuration file.
  1783.  
  1784.    3. Unix: I installed PHP, but every time I load a document, I get the
  1785.    message 'Document Contains No Data'! What's going on here?
  1786.  
  1787.    This probably means that PHP is having some sort of problem and is
  1788.    core-dumping. Look in your server error log to see if this is the
  1789.    case, and then try to reproduce the problem with a small test case. If
  1790.    you know how to use 'gdb', it is very helpful when you can provide a
  1791.    backtrace with your bug report to help the developers pinpoint the
  1792.    problem. If you are using PHP as an Apache module try something like:
  1793.  
  1794.      * Stop your httpd processes
  1795.      * gdb httpd
  1796.      * Stop your httpd processes
  1797.      * > run -X -f /path/to/httpd.conf
  1798.      * Then fetch the URL causing the problem with your browser
  1799.      * > run -X -f /path/to/httpd.conf
  1800.      * If you are getting a core dump, gdb should inform you of this now
  1801.      * type: bt
  1802.      * You should include your backtrace in your bug report. This should
  1803.        be submitted to http://bugs.php.net/
  1804.  
  1805.    If your script uses the regular expression functions (ereg() and
  1806.    friends), you should make sure that you compiled PHP and Apache with
  1807.    the same regular expression package. This should happen automatically
  1808.    with PHP and Apache 1.3.x
  1809.  
  1810.    4. Unix: I installed PHP using RPMS, but Apache isn't processing the
  1811.    PHP pages! What's going on here?
  1812.  
  1813.    Assuming you installed both Apache and PHP from RPM packages, you need
  1814.    to uncomment or add some or all of the following lines in your
  1815.    httpd.conf file:
  1816. # Extra Modules
  1817. AddModule mod_php.c
  1818. AddModule mod_php3.c
  1819. AddModule mod_perl.c
  1820.  
  1821. # Extra Modules
  1822. LoadModule php_module         modules/mod_php.so
  1823. LoadModule php3_module        modules/libphp3.so     # for PHP 3
  1824. LoadModule php4_module        modules/libphp4.so     # for PHP 4
  1825. LoadModule perl_module        modules/libperl.so
  1826.  
  1827.    And add:
  1828. AddType application/x-httpd-php3 .php3    # for PHP 3
  1829. AddType application/x-httpd-php .php      # for PHP 4
  1830.  
  1831.    ... to the global properties, or to the properties of the
  1832.    VirtualDomain you want to have PHP support added to.
  1833.  
  1834.    5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the
  1835.    database support I need! What's going on here?
  1836.  
  1837.    Due to the way PHP 3 built, it is not easy to build a complete
  1838.    flexible PHP RPM. This issue is addressed in PHP 4. For PHP 3, we
  1839.    currently suggest you use the mechanism described in the
  1840.    INSTALL.REDHAT file in the PHP distribution. If you insist on using an
  1841.    RPM version of PHP 3, read on...
  1842.  
  1843.    The RPM packagers are setting up the RPMS to install without database
  1844.    support to simplify installations and because RPMS use /usr/ instead
  1845.    of the standard /usr/local/ directory for files. You need to tell the
  1846.    RPM spec file which databases to support and the location of the
  1847.    top-level of your database server.
  1848.  
  1849.    This example will explain the process of adding support for the
  1850.    popular MySQL database server, using the mod installation for Apache.
  1851.  
  1852.    Of course all of this information can be adjusted for any database
  1853.    server that PHP supports. We will assume you installed MySQL and
  1854.    Apache completely with RPMS for this example as well.
  1855.  
  1856.      * First remove mod_php3 :
  1857.  
  1858. rpm -e mod_php3
  1859.  
  1860.      * Then get the source rpm and INSTALL it, NOT --rebuild
  1861.  
  1862. rpm -Uvh mod_php3-3.0.5-2.src.rpm
  1863.  
  1864.      * Then edit the /usr/src/redhat/SPECS/mod_php3.spec file
  1865.        In the %build section add the database support you want, and the
  1866.        path.
  1867.        For MySQL you would add --with-mysql=/usr The %build section will
  1868.        look something like this:
  1869.  
  1870. ./configure --prefix=/usr \
  1871. --with-apxs=/usr/sbin/apxs \
  1872. --with-config-file-path=/usr/lib \
  1873. --enable-debug=no \
  1874. --enable-safe-mode \
  1875. --with-exec-dir=/usr/bin \
  1876. --with-mysql=/usr \
  1877. --with-system-regex
  1878.  
  1879.      * Once this modification is made then build the binary rpm as
  1880.        follows:
  1881.  
  1882. rpm -bb /usr/src/redhat/SPECS/mod_php3.spec
  1883.  
  1884.      * Then install the rpm
  1885.  
  1886. rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm
  1887.  
  1888.    Make sure you restart Apache, and you now have PHP 3 with MySQL
  1889.    support using RPM's. Note that it is probably much easier to just
  1890.    build from the distribution tarball of PHP 3 and follow the
  1891.    instructions in INSTALL.REDHAT found in that distribution.
  1892.  
  1893.    6. Unix: I patched Apache with the FrontPage extensions patch, and
  1894.    suddenly PHP stopped working. Is PHP incompatible with the Apache
  1895.    FrontPage extensions?
  1896.  
  1897.    No, PHP works fine with the FrontPage extensions. The problem is that
  1898.    the FrontPage patch modifies several Apache structures, that PHP
  1899.    relies on. Recompiling PHP (using 'make clean ; make') after the FP
  1900.    patch is applied would solve the problem.
  1901.  
  1902.    7. Unix/Windows: I have installed PHP, but when I try to access a PHP
  1903.    script file via my browser, I get a blank screen.
  1904.  
  1905.    Do a 'view source' in the web browser and you will probably find that
  1906.    you can see the source code of your PHP script. This means that the
  1907.    web server did not send the script to PHP for interpretation.
  1908.    Something is wrong with the server configuration - double check the
  1909.    server configuration against the PHP installation instructions.
  1910.  
  1911.    8. Unix/Windows: I have installed PHP, but when try to access a PHP
  1912.    script file via my browser, I get a server 500 error.
  1913.  
  1914.    Something went wrong when the server tried to run PHP. To get to see a
  1915.    sensible error message, from the command line, change to the directory
  1916.    containing the PHP executable (php.exe on Windows) and run php -i. If
  1917.    PHP has any problems running, then a suitable error message will be
  1918.    displayed which will give you a clue as to what needs to be done next.
  1919.    If you get a screen full of HTML codes (the output of the phpinfo()
  1920.    function) then PHP is working, and your problem may be related to your
  1921.    server configuration which you should double check.
  1922.  
  1923.    9. Some operating systems: I have installed PHP without errors, but
  1924.    when I try to start apache I get undefined symbol errors:
  1925. [mybox:user /src/php4] root# apachectl configtest
  1926.  apachectl: /usr/local/apache/bin/httpd Undefined symbols:
  1927.   _compress
  1928.   _uncompress
  1929.  
  1930.    This has actually nothing to do with PHP, but with the MySQL client
  1931.    libraries. Some need --with-zlib, others do not. This is also covered
  1932.    in the MySQL FAQ.
  1933.  
  1934.    10. Windows: I have installed PHP, but when I to access a PHP script
  1935.    file via my browser, I get the error:
  1936. cgi error:
  1937.  The specified CGI application misbehaved by not
  1938.  returning a complete set of HTTP headers.
  1939.  The headers it did return are:
  1940.  
  1941.    This error message means that PHP failed to output anything at all. To
  1942.    get to see a sensible error message, from the command line, change to
  1943.    the directory containing the PHP executable (php.exe on Windows) and
  1944.    run php -i. If PHP has any problems running, then a suitable error
  1945.    message will be displayed which will give you a clue as to what needs
  1946.    to be done next. If you get a screen full of HTML codes (the output of
  1947.    the phpinfo() function) then PHP is working.
  1948.  
  1949.    Once PHP is working at the command line, try accessing the script via
  1950.    the browser again. If it still fails then it could be one of the
  1951.    following:
  1952.  
  1953.      * File permissions on your PHP script, php.exe, php4ts.dll, php.ini
  1954.        or any PHP extensions you are trying to load are such that the
  1955.        anonymous internet user ISUR_<machinename> cannot access them.
  1956.      * The script file does not exist (or possibly isn't where you think
  1957.        it is relative to your web root directory). Note that for IIS you
  1958.        can trap this error by ticking the 'check file exists' box when
  1959.        setting up the script mappings in the Internet Services Manager.
  1960.        If a script file does not exist then the server will return a 404
  1961.        error instead. There is also the additional benefit that IIS will
  1962.        do any authentication required for you based on the NTLanMan
  1963.        permissions on your script file.
  1964.  
  1965.    11. Windows: I've followed all the instructions, but still can't get
  1966.    PHP and IIS to work together!
  1967.  
  1968.    Make sure any user who needs to run a PHP script has the rights to run
  1969.    php.exe! IIS uses an anonymous user which is added at the time IIS is
  1970.    installed. This user needs rights to php.exe. Also, any authenticated
  1971.    user will also need rights to execute php.exe. And for IIS4 you need
  1972.    to tell it that PHP is a script engine. Also, you will want to read
  1973.    this faq.
  1974.  
  1975.    12. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get
  1976.    the following error: Security Alert! PHP CGI cannot be accessed
  1977.    directly..
  1978.  
  1979.    You must set the cgi.force_redirect directive to 0. It defaults to 1
  1980.    so be sure the directive isn't commented out (with a ;). Like all
  1981.    directives, this is set in php.ini
  1982.  
  1983.    Because the default is 1, it's critical that you're 100% sure that the
  1984.    correct php.ini file is being read. Read this faq for details.
  1985.  
  1986.    13. How do I know if my php.ini is being found and read? It seems like
  1987.    it isn't as my changes aren't being implemented.
  1988.  
  1989.    To be sure your php.ini is being read by PHP, make a call to phpinfo()
  1990.    and near the top will be a listing called Configuration File
  1991.    (php.ini). This will tell you where PHP is looking for php.ini and
  1992.    whether or not it's being read. If just a directory PATH exists than
  1993.    it's not being read and you should put your php.ini in that directory.
  1994.    If php.ini is included within the PATH than it is being read.
  1995.  
  1996.    If php.ini is being read and you're running PHP as a module, then be
  1997.    sure to restart your web server after making changes to php.ini
  1998.  
  1999.    14. How do I add my PHP directory to the PATH on Windows?
  2000.  
  2001.    On Windows NT, 2000, XP and 2003:
  2002.  
  2003.      * Go to Control Panel and open the System icon (Start -> Settings ->
  2004.        Control Panel -> System, or just Start -> Control Panel -> System
  2005.        for Windows XP/2003)
  2006.      * Go to the Advanced tab
  2007.      * Click on the 'Environment Variables' button
  2008.      * Look into the 'System Variables' pane
  2009.      * Find the Path entry (you may need to scroll to find it)
  2010.      * Double click on the Path entry
  2011.      * Enter your PHP directory ant the end, including ';' before (e.g.
  2012.        ;C:\php)
  2013.      * Press OK and restart your computer
  2014.  
  2015.    On Windows 98/Me you need to edit the autoexec.bat file:
  2016.  
  2017.      * Open the Notepad (Start -> Run and enter notepad)
  2018.      * Open the C:\autoexec.bat file
  2019.      * Locate the line with PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;..... and
  2020.        add: ;C:\php to the end of the line
  2021.      * Save the file and restart your computer
  2022.  
  2023.      Note: Be sure to reboot after following the steps above to ensure
  2024.      that the PATH changes are applied.
  2025.  
  2026.    The PHP manual used to promote the copying of files into the Windows
  2027.    system directory, this is because this directory (C:\Windows,
  2028.    C:\WINNT, etc.) is by default in the systems PATH. Copying files into
  2029.    the Windows system directory has long since been deprecated and may
  2030.    cause problems.
  2031.  
  2032.    15. How do I make the php.ini file available to PHP on windows?
  2033.  
  2034.    There are several ways of doing this. If you are using Apache, read
  2035.    their installation specific instructions (Apache 1, Apache 2),
  2036.    otherwise you must set the PHPRC environment variable:
  2037.  
  2038.    On Windows NT, 2000, XP and 2003:
  2039.  
  2040.      * Go to Control Panel and open the System icon (Start -> Settings ->
  2041.        Control Panel -> System, or just Start -> Control Panel -> System
  2042.        for Windows XP/2003)
  2043.      * Go to the Advanced tab
  2044.      * Click on the 'Environment Variables' button
  2045.      * Look into the 'System variables' pane
  2046.      * Click on 'New' and enter 'PHPRC' as the variable name and the
  2047.        directory where php.ini is located as the variable value (e.g.
  2048.        C:\php)
  2049.      * Press OK and restart your computer
  2050.  
  2051.    On Windows 98/Me you need to edit the autoexec.bat file:
  2052.  
  2053.      * Open the Notepad (Start -> Run and enter notepad)
  2054.      * Open the C:\autoexec.bat file
  2055.      * Add a new line to the end of the file: set PHPRC=C:\php (replace
  2056.        C:\php with the directory where php.ini is located). Please note
  2057.        that the path cannot contain spaces. For instance, if you have
  2058.        installed PHP in C:\Program Files\PHP, you would enter
  2059.        C:\PROGRA~1\PHP instead.
  2060.      * Save the file and restart your computer
  2061.  
  2062.    16. Is it possible to use Apache content negotiation (MultiViews
  2063.    option) with PHP?
  2064.  
  2065.    If links to PHP files include extension, everything works perfect.
  2066.    This FAQ is only for the case when links to PHP files don't include
  2067.    extension and you want to use content negotiation to choose PHP files
  2068.    from URL with no extension. In this case, replace the line AddType
  2069.    application/x-httpd-php .php with:
  2070. # PHP 4
  2071. AddHandler php-script php
  2072. AddType text/html php
  2073.  
  2074. # PHP 5
  2075. AddHandler php5-script php
  2076. AddType text/html php
  2077.  
  2078.    This solution doesn't work for Apache 1 as PHP module doesn't catch
  2079.    php-script.
  2080.  
  2081.    17. Is PHP limited to process GET and POST request methods only?
  2082.  
  2083.    No, it is possible to handle any request method, e.g. CONNECT. Proper
  2084.    response status can be sent with header(). If only GET and POST
  2085.    methods should be handled, it can be achieved with this Apache
  2086.    configuration:
  2087. <LimitExcept GET POST>
  2088. Deny from all
  2089. </LimitExcept>
  2090.