mercredi 29 octobre 2014

Setup Apache 2.2 for FastCgi handling of PHP on windows 7

Why ?
Because I used to setup PHP as an Apache Module. But, this morning, after starting my good old 2012 apache2.2 service, it says "mysql driver not installed"! I'm quite sure they were in 2012. In addition, IIS, on the same php.ini, says they are installed. So I try Apache with FastCGI as IIS does. Then, my drivers come back.
We here assume that
  • Apache 2.2 is yet installed.
  • php5 is in a directory named c:\php-5
From this assumptions:
Edit httpd.conf as follow:
    #LoadModule php5_module "c:/php-5/php5apache2_2.dll"
    #AddHandler application/x-httpd-php .php
    #PHPIniDir "C:/php-5"

    LoadModule fcgid_module modules/mod_fcgid.so
    FcgidInitialEnv PHPRC "c:/php-5"
    AddHandler fcgid-script .php
    FcgidWrapper "c:/php-5/php-cgi.exe" .php
And, to avoid HTTP 403 errors, don't forget ExecCGI in your directory configuration.
    
        Options Indexes FollowSymLinks ExecCGI
        #...
    
By the way, mod_fcgid.so can be found here (http://mir2.ovh.net/ftp.apache.org/dist//httpd/binaries/win32/)
I'm on a windows 7 64bits professional edition.