Posts Tagged ‘php’

PHP – problem trying to connect with Informix on IIS

I was working on a project which needs PHP talk to Informix database on Windows platform. After installed IBM Informix Client_SDK, included PHP extension php_ifx.dll, and use following command to connect to Informix:

$sync_link_id = ifx_connect($database, $username, $password);

I got following error:

[SQLSTATE=IX 000 SQLCODE=-25560]

If you check Informix document from IBM, you know Environment variable INFORMIXSERVER must be set. We know how to set up environment variable on Unix and Apache, but the question is how to set it up for IIS?

People may first think this could be environment variable on Windows as well. But this is wrong. Informix client is using Registry KEY on Windows platform. Here is the path on a 64bit machine.

HKEY_LOCAL_MACHINE\Software\Wow6432Node\Informix\Environment\

Second, you should have your default server setup under KEY:

HKEY_LOCAL_MACHINE\Software\Wow6432Node\Informix\SqlHosts\

At here, you need to provide HOST, PROTOCOL and SERVICE, so php_ifx knows how to connect to your Informix server.

After set them up, PHP should be able to talk to Informix.

Using PHP FastCGI mode on Windows Server 2003 x64 w/ IIS in 32-bit mode

I recently needed to upgrade the PHP for a particular site from 5.2.6 to 5.3.0.  Of course, this is when I found out that PHP no longer supports the ISAPI module and instead wants you to use FastCGI.  Luckily I found a great article on how to configure IIS at http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/.  However, these instructions have some caveats in regards to running IIS in 32 bit mode on Windows Server 2003 x64.  To make a long story short, just like with most things running in 32 bit mode on x64, everything that references %WINDIR%\system32 really needs to point to %WINDIR%\SysWOW64.  If you use the fcgiconfig.js script, this will configure everything to point to %WINDIR%\system32.

  • The Web Service Extension needs to point to %WINDIR%\SysWOW64\inetsrv\fcgiext.dll.
  • The .php extension on the website also needs to point to %WINDIR%\SysWOW64\inetsrv\fcgiext.dll.
  • The fcgiext.ini file must also be located in %WINDIR%\SysWOW64\inetsrv.  Otherwise you will get a 500 error from FastCGI saying it cannot find the configuration file.

Note that the fcgiconfig.js script is only installed in %WINDIR%\system32\inetsrv.  I was able to create a fcgiconfigwow64.js file that points to the correct files.  The script needs to have at least an ini file with the “[Types]” section in the %WINDIR%\SysWOW64\inetsrv directory.  It also needs to be located under %WINDIR%\system32 as it doesn’t support running under Wow64.  You just need to change the following 2 lines near the top of the script.

From:

var g_iniPath       = g_Shell.ExpandEnvironmentStrings( "%WinDir%\\system32\\inetsrv\\fcgiext.ini" );
var g_extensionPath = g_Shell.ExpandEnvironmentStrings( "%WinDir%\\system32\\inetsrv\\fcgiext.dll" );

To:

var g_iniPath       = g_Shell.ExpandEnvironmentStrings( "%WinDir%\\SysWOW64\\inetsrv\\fcgiext.ini" );
var g_extensionPath = g_Shell.ExpandEnvironmentStrings( "%WinDir%\\SysWOW64\\inetsrv\\fcgiext.dll" );