Apache multi virtual host multi version PHP (5.2 + 5.3 + 5.4) Co running configuration

1. Download the corresponding mod_fcgid-2.3.9-win64-VC14.zip according to the apache version

Extract fcgid, and take its mod_fcgid.so to the modules directory.

Each version of PHP is decompressed to different directories and configured. It is convenient to use any location.

2. Open httpd.conf to comment out the following similar configurations

#LoadModule php5_module "D:/php53/php5apache2_2.dll"
#PHPIniDir "D:/php53/"

3. Add configuration (just at the tail or middle)

#Load the fcgid extension module (additional note: fcgid corresponds to the actual apache version, and the apache 2 version test is normal in 2.3.6)
LoadModule fcgid_module modules/mod_fcgid.so
#add mapping
AddHandler fcgid-script .fcgi .php
#Set PHP fcgi Max requests to be greater than or equal to FcgidMaxRequestsPerProcess to prevent PHP CGI process from exiting before all requests are processed
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
#Maximum requests per process for PHP CGI
FcgidMaxRequestsPerProcess 1000
#The maximum number of processes in PHP CGI
FcgidMaxProcesses 3
#Maximum execution time
FcgidIOTimeout 120
FcgidIdleTimeout 120
#Limit maximum request bytes (unit b)
FcgidMaxRequestLen 2097152

AddType application/x-httpd-php .php
#------This is the default virtual host configuration
#Storage directory of php.ini
FcgidInitialEnv PHPRC "D:/php5.4.4/"
#The path of PHP CGI
FcgidWrapper "D:/php5.4.4/php-cgi.exe" .php

4. Modify add execution permission (if not, HTTP error may be prompted and access to 403 is forbidden)

ExecCGI is added value

<Directory />
    Options FollowSymLinks ExecCGI
    AllowOverride None
    Order deny,allow
    Deny from all

5. Virtual host file configuration (only the configuration version path needs to be changed in the independent configuration section of each virtual host. The following configuration is PHP5.3.1 virtual host configuration)

<VirtualHost *:80>
      ServerName "apihost"
      ServerAlias www.apihost.com api.apihost.com
      FcgidInitialEnv PHPRC "D:/php5.3.1/"
      FcgidWrapper "D:/php5.3.1/php-cgi.exe" .php
      DocumentRoot "D:/WEB/apihost/wwwroot/"
      ErrorLog "D:/WEB/apihost/log/error.log"
      CustomLog "D:/WEB/apihost/log/access.log" common

6. Restart Apache to finish!

Tags: Programming PHP Apache

Posted on Mon, 09 Dec 2019 19:18:23 -0800 by Balu