Inhaltsverzeichnis
Dieses Kapitel stellt eine Schnellanleitung für die Konfiguration von Apache dar. Sie erfahren, welche Einstellungen notwendig sind, damit Sie PHP mit Apache betreiben können. Die folgenden Angaben stellen dabei die Einstellungen für Apache in den Versionen 1.3.x und 2.x sowie für PHP in den Versionen 4 und 5 vor.
Nähere Informationen zum Apache-Webserver finden Sie unter httpd.apache.org/. Die PHP-Dokumentation als auch die PHP-Programmdateien können Sie sich unter www.php.net herunterladen.
Wenn Sie Apache neu installieren, müssen Sie es für den Betrieb mit PHP konfigurieren. Sie können dabei PHP sowohl als Modul als auch als CGI-Programm installieren.
Apache 2: PHP als Modul
Um PHP 4.x unter Apache 2.x als Modul zu installieren, können Sie folgenden Text in die Konfigurationsdatei (httpd.conf ) eingeben:
Beispiel B.1. PHP 4.x als Modul unter Apache 2.x
# For PHP 4 do something like this: LoadModule php4_module "c:/php/php4apache2.dll" # Don't forget to copy the php4apache2.dll file from the # sapi directory! AddType application/x-httpd-php .php # configure the path to php.ini PHPIniDir "C:/php"
Bei PHP 4.x befindet sich das PHP-Modul „php4apache2.dll“ im
Unterverzeichnis C:\php\sapi\. Sie müssen die
dll-Datei also in das Wurzelverzeichnis Ihrer PHP-Installation ‒
beispielsweise C:\php\ ‒ verschieben.
Um PHP 5.x unter Apache 2.x als Modul zu installieren, können Sie
folgenden Text in die Konfigurationsdatei httpd.conf
eingeben:
Beispiel B.2. PHP 5.x als Modul unter Apache 2.x
# For PHP 5 do something like this: LoadModule php5_module "c:/php/php5apache2.dll" AddType application/x-httpd-php .php # configure the path to php.ini PHPIniDir "C:/php"
Apache 2: PHP als CGI
Um PHP 4.x unter Apache 2.x als CGI zu installieren, müssen Sie folgende Direktiven in die Konfigurationsdatei Ihres Webservers eingeben:
Beispiel B.3. PHP 4.x als CGI unter Apache 2.x
ScriptAlias /php/ "c:/php/" AddType application/x-httpd-php .php # For PHP 4 Action application/x-httpd-php "/php/php.exe"
Um PHP 5.x unter Apache 2.x als CGI zu installieren, müssen Sie folgende Direktiven in die Konfigurationsdatei Ihres Webservers eingeben.
Beispiel B.4. PHP 5.x als CGI unter Apache 2.x
ScriptAlias /php/ "c:/php/" AddType application/x-httpd-php .php # For PHP 5 Action application/x-httpd-php "/php/php-cgi.exe"
Apache 1.3.x: PHP als Modul
Um PHP 4.x unter Apache 1.3.x als Modul zu installieren, geben Sie folgende Direktiven in die Konfigurationsdatei Ihres Webservers ein:
Beispiel B.5. PHP 4.x als Modul unter Apache 1.3.x
# 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
Bei PHP 4.x befindet sich das PHP-Modul „php4apache2.dll“ im
Unterverzeichnis C:\php\sapi\. Sie müssen die
dll-Datei also in das Wurzelverzeichnis Ihrer PHP-Installation ‒ bspw.
C:\php\ ‒ verschieben.
Um PHP 5.x unter Apache 1.3.x als Modul zu installieren, geben Sie folgende Direktiven in die Konfigurationsdatei Ihres Webservers ein:
Beispiel B.6. PHP 5.x als Modul unter Apache 1.3.x
# 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
In beiden Fällen müssen Sie innerhalb des <IfModule
mod_mime.c>-Tags den Mime-Typ angeben:
Beispiel B.7. MIME-Typ unter Apache 1.3.x angeben
# 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
Apache 1.3.x: PHP als CGI
Um PHP 4.x unter Apache 1.3. x als CGI zu installieren, geben Sie folgende Direktiven in die Konfigurationsdatei Ihres Servers ein:
Beispiel B.8. PHP 4.x als CGI unter Apache 1.3.x
# For PHP 4 Action application/x-httpd-php "/php/php.exe"
Um PHP 5.x unter Apache 1.3.x als CGI zu installieren, geben Sie folgende Direktiven in die Konfigurationsdatei Ihres Servers ein:
Beispiel B.9. PHP 5.x als CGI unter Apache 1.3.x
# For PHP 5 Action application/x-httpd-php "/php/php-cgi.exe"
Des Weiteren müssen Sie für beide oben genannten PHP-Versionen
- den MIME-Typ angeben,
- das Verzeichnis zur
php.iniangeben und - die ScriptAlias-Direktive angeben.
Geben Sie dazu folgende Zeilen in die Konfigurationsdatei Ihres Webservers ein:
Beispiel B.10. PHP unter Apache 1.3.x konfigurieren
ScriptAlias /php/ "c:/php/" AddType application/x-httpd-php .php # specify the directory where php.ini is SetEnv PHPRC C:/php
