Podręcznik PHP
Poprzedni | Rozdział 6. Installation on Windows systems | Następny

# Apache 1.3.x on Microsoft Windows

This section contains notes and hints specific to Apache 1.3.x installs of PHP on Microsoft Windows systems. There are also instructions and notes for Apache 2 on a separate page.

> Notatka: Please read the manual installation steps first!

There are two ways to set up PHP to work with Apache 1.3.x on Windows. One is to use the CGI binary (`php.exe` for PHP 4 and `php-cgi.exe` for PHP 5), the other is to use the Apache Module DLL. In either case you need to edit your `httpd.conf` to configure Apache to work with PHP, and then restart the server.

It is worth noting here that now the SAPI module has been made more stable under Windows, we recommend it's use above the CGI binary, since it is more transparent and secure.

Although there can be a few variations of configuring PHP under Apache, these are simple enough to be used by the newcomer. Please consult the Apache Documentation for further configuration directives.

After changing the configuration file, remember to restart the server, for example, NET STOP APACHE followed by NET START APACHE, if you run Apache as a Windows Service, or use your regular shortcuts.

> Notatka: Nalezy pamiętać, że podając ścieżki w plikach konfiguracyjnych Apache w systemie Windows, wszystkie znaki backslash takie jak na przykład w ścieżce `c:\directory\file.ext` muszą być zamienione na znaki slash, na przykład `c:/directory/file.ext`.

## Installing as an Apache module

You should add the following lines to your Apache `httpd.conf` file:

Przykład 6-3. PHP as an Apache 1.3.x module

This assumes PHP is installed to `c:\php`. Adjust the path if this is not the case.

For PHP 4:

    # Add to the end of the LoadModule section
    # Don't forget to copy this file from the sapi directory!
    LoadModule php4_module "C:/php/php4apache.dll"

    # Add to the end of the AddModule section
    AddModule mod_php4.c

For PHP 5:

    # Add to the end of the LoadModule section
    LoadModule php5_module "C:/php/php5apache.dll"

    # Add to the end of the AddModule section
    AddModule mod_php5.c

For both:

    # Add this line inside the <IfModule mod_mime.c> conditional brace
    AddType application/x-httpd-php .php

    # For syntax highlighted .phps files, also add
    AddType application/x-httpd-php-source .phps

## Installing as a CGI binary

If you unzipped the PHP package to `C:\php\` as described in the Manual Installation Steps section, you need to insert these lines to your Apache configuration file to set up the CGI binary:

Przykład 6-4. PHP and Apache 1.3.x as CGI

    ScriptAlias /php/ "c:/php/"
    AddType application/x-httpd-php .php

    # For PHP 4
    Action application/x-httpd-php "/php/php.exe"

    # For PHP 5
    Action application/x-httpd-php "/php/php-cgi.exe"

    # specify the directory where php.ini is
    SetEnv PHPRC C:/php

Note that the second line in the list above can be found in the actual versions of `httpd.conf`, but it is commented out. Remember also to substitute the `c:/php/` for your actual path to PHP.

Ostrzeżenie
Używając instalacji CGI, serwer jest podatny na wiele potencjalnych ataków. Sposoby obrony przed nimi zostały opisane w rozdziale o bezpieczeństwie instalacji CGI.

If you would like to present PHP source files syntax highlighted, there is no such convenient option as with the module version of PHP. If you chose to configure Apache to use PHP as a CGI binary, you will need to use the highlight_file() function. To do this simply create a PHP script file and add this code: <?php highlight_file('some_php_script.php'); ?>.

Poprzedni | Spis treści | Następny
Microsoft IIS / PWS | Początek rozdziału | Apache 2.0.x on Microsoft Windows