Heim  >  Artikel  >  Backend-Entwicklung  >  Mehrere Arbeitsmethoden von PHP unter Apache

Mehrere Arbeitsmethoden von PHP unter Apache

伊谢尔伦
伊谢尔伦Original
2016-11-25 13:55:241024Durchsuche

1. CGI-Modus

CGI-Modus von PHP in Apache 2. Bearbeiten Sie die Apache-Konfigurationsdatei httpd.conf wie folgt:

# PHP4-Versionsschreibmethode
ScriptAlias ​​/php/ "D:/php/"
AddType application/x-httpd-php . php
Aktion application/x-httpd-php "/php/php.exe"
# Schreibmethode der PHP5-Version
ScriptAlias ​​/php/ "D:/php/"
AddType application/ x-httpd-php .php
Aktion application/x-httpd-php "/php/php-cgi.exe"

2. Apache-Modulmodus

PHP-Modulmodus in Apache 2. Bearbeiten Sie die Apache-Konfigurationsdatei httpd.conf wie folgt:

# PHP4 version writing
LoadModule php4_module "D:/php/php4apache2.dll"
AddType application/x-httpd-php .php
# Vergessen Sie nicht, php4apache2.dll aus dem Sapi-Verzeichnis zu kopieren!
# Methode zum Schreiben der PHP5-Version
LoadModule php5_module „D:/php/php5apache2.dll“
AddType application/x-httpd-php .php
PHPIniDir „D:/php“
# PHPIniDir Wird verwendet, um den Pfad der PHP-Konfigurationsdatei php.ini anzugeben

3. FastCGI-Modus

Das FastCGI-Modul unter Apache hat derzeit zwei Versionen im Internet, mod_fastcgi und mod_fcgid. Es wird empfohlen, mod_fcgid zu verwenden.

Verwenden Sie mod_fcgid, um den FastCGI-Modus zu konfigurieren

Laden Sie mod_fcgid herunter und kopieren Sie die Datei „mod_fcgid.so“ im komprimierten Paket in das Verzeichnis „modules“ von Apache. Öffnen Sie die httpd.conf-Datei von Apache und fügen Sie am Ende die folgende Konfiguration hinzu:

LoadModule fcgid_module modules/mod_fcgid.so
<IfModule mod_fcgid.c>
    AddHandler fcgid-script .fcgi .php
    #php.ini的存放目录
    FcgidInitialEnv PHPRC "D:/PHP"
    # 设置PHP_FCGI_MAX_REQUESTS大于或等于FcgidMaxRequestsPerProcess,防止php-cgi进程在处理完所有请求前退出
    FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
    #php-cgi每个进程的最大请求数
    FcgidMaxRequestsPerProcess 1000
    #php-cgi最大的进程数
    FcgidMaxProcesses 5
    #最大执行时间
    FcgidIOTimeout 120
    FcgidIdleTimeout 120
    #php-cgi的路径
    FcgidWrapper "D:/PHP/php-cgi.exe" .php
    AddType application/x-httpd-php .php
</IfModule>

Ändern Sie die DocumentRoot-Pfadkonfiguration in:

<Directory "D:/WWW">  
    Options Indexes FollowSymLinks ExecCGI    Order allow,deny  
    Allow from all
    AllowOverride All
</Directory>


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn