ponedeljek, 16. februar 2015

connect to mssql via 64 bit

To be able to use current Apache on windows compiled for 64bit first we need to download binary version (can be also build form source - but this would be more rational way). One of suggested sites offers such version (httpd-2.4.12-x64-vc11.zip) is https://www.apachehaus.com. After trivial unzip and copy to local hard setting SRVROOT variable in httpd.conf would be wise thing to do. In my case:

Define SRVROOT "C:\work\Apache24"

After that, adding Apache as service so it gets started on machine boot and ability to use Apache monitor for quick access of restarting service is always good thing.

From bin folder just run:

httpd.exe -k install

In theory trying to load localhost in your browser should return some sort of landing page.

Next thing would be install of php, since using 64bit Apache we go for 64bit of php version also. At time of install VC11 x64 Non Thread Safe (2015-Jan-22 03:24:53) this was last version so i picked this one here http://windows.php.net/download#php-5.6. Again trivial unzip would do just fine - but if u go for c:\php folder might save u some config changing later.

To tie things together we need to download fcgi from apachehouse - mod_fcgid-2.3.9-2.4.x-x64.zip this matches our current installation stack. Just unzib contents into Apache root folder - we het module, config and some readme's.

Two things are needed to actually load this. Again open httpd.conf and add this two lines.

LoadModule fcgid_module modules/mod_fcgid.so
Include conf/extra/httpd-fcgid.conf


First line loads fcgi module and second one includes fcgi configuration into apache.

At this point we can make php file inside htdocs folder with phpinfo() command and see some standard phpinfo output about our configuration.

Now we can try connect to mssql. For this we would need 64bit library for php to connect to mssql which Microsoft is not providing - but thats where Rob jumps in - providing precompiled 64bit librarys for connecting to mssql here http://robsphp.blogspot.com/2012/06/unofficial-microsoft-sql-server-driver.html. After download just copy files form x64 folder into ext folder of php installation, add  extension loading to php.ini and restart Apache service.

extension=ext/php_sqlsrv_55_ts.dll

Now phpini() should inform us about loaded extension.


If sql server is installed on other machine now would be good time to install native client for sql server found here https://msdn.microsoft.com/en-us/sqlserver/aa937733.aspx. If you are installing on same machine that runs sql server there is good chance you already have this installed and can skip this step.

Last step would be to add some table/data into sql server to test everything (i always try to test uft-8 since our alphabet includes some weird characters that lived inside ut8) - so adding extra parameter to connection string is a good thing ... and success.