Install PHP 5. 4. IIS 7 to work with MS SQL 2. Deep Shift Labs Development Blog. I decided to write this post because I have not found a simple and clear description for installing PHP on Windows, and setting this not very common combination to work with MS SQL 2. We are currently working on porting the largest system ever created in Deep Shift Labs from Windows 2. MS SQL 2. 00. 0 to Windows 2.
MS SQL 2. 00. 8. I want to speak briefly about the history of this system and why we actually needed to install PHP on Windows. The system is about 8. K lines of PHP code and it has been helping people to solve their business needs for the last 1. This system is designed for one of our customers. The first few years, the system worked on Free. BSD, Apache and Postgre. SQL. Then the client’s company went public, and they needed to switch to commercial software.
Sometime in 2. 00. ADODB, to move, with a little effort, from Free. BSD/Apache to Windows 2.
IIS 5 (PHP runs as an ISAPI module). Finally, in 2. 00. MS SQL 2. 00. 0 from Postgre.
Installation. As of PHP 5.2.0, the JSON extension is bundled and compiled into PHP by default. Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. # cd /usr/ports/databases/php5-mssql 또는 /usr/ports/databases/php4-mssql # make # make install. FreeBSDサーバー構築マニュアルは、FreeBSD8,FreeBSD9で安定した自宅サーバーの構築手順を紹介しています。.
SQL. The most difficult part in the distant 2. MS SQL. We had tried everything supported by ADODB back then, and, in the end, we decided in favor of php_dblib. Frank Kromann. Frank was maintaining MS SQL extensions in PHP project and helped us immensely. The php_mssql. dll driver was using ntwdblib. Microsoft, that does not work with dates and long texts properly. Free. TDS and we have not found any problems in it and started using it. And now came the moment when the customer wants to move to the operating system and database that have Microsoft support (Windows 2.
MS SQL 2. 00. 0 are not supported anymore) and such a move, in general, is a common requirement in large enterprises. Naturally, in the ADODB 4. Move the database from MS SQL 2. MS SQL 2. 00. 8- Move the web server from Windows 2. IIS 5 (ISAPI) on Windows 2.
IIS 7 (Fast. CGI)- Upgrade PHP 5. PHP 5. 4. 6- Upgrade ADODB from 4. To test the system, including the two replications processes to our database from servers running MS SQL 2. MS SQL 2. 00. 5. This is one of the installation methods (obviously the one we used). Create C: \PHP and C: \tmp folders. Load non thread safe PHP version recommended for use here and here.
The file will contain _nts_ in the name, for example – php- 5. Win. 32- VC9- x. 86. Unpack it in C: \PHP4. Load latest drivers from MS SQL Microsoft (file SQLSRV3. C: \PHP\ext. 5. Download the PHP web installer from Microsoft.
They offer two versions and I used the latter one available with PHP 5. Install it. You can ask a reasonable question why we install 5. There are two reasons.
First – I did not manage to set PHP 5. IIS. Despite my attempts to let PHP see its php. C: \PHP I failed to do so. According to all the manuals you need to create a variable PHPRC assigning the path to php. Since PHP couldn’t see the configuration file, MS SQL driver was not loaded. Being stuck at this point for a couple of hours I asked for help in the forum and started looking for alternatives, waiting until America wakes up and sees my ‘SOS’ message in the forum.
It was then that I accidentally came across a site where I found the alternative I was looking for. Maybe I would not have started using the installer if it had not offered to set this magical and wonderful PHP Manager I could not resist at the thought of trying. In the end I found that the PHP Manager allows adding PHP 5. It installs all the necessary components as well. It took some 1. 0 years for Microsoft to add some really cool things to run PHP on Windows – here you have MS SQL driver and the installer which adds a special PHP Manager inside IIS, and even Windows Cache PHP accelerator for IIS.
I am using an Apache web server and PHP 5 server-side scripting language to produce dynamic web pages for our corporate website. How do I install install php gd support on an Apache/PHP5 for dynamically manipulating. Installing on FreeBSD. The Suhosin-Patch and the Suhosin extension are both within the FreeBSD ports. Therefore installing it on FreeBSD is very simple. The Suhosin-Patch is an option which you can choose when you install the. To install on Ubuntu or Debian, using the package manager, use: sudo apt-get install php5-imagick sudo service apache2 reload.
After installation, we have PHP 5. Program Files and PHP Manager inside IIS. As you can see from the PHP Manager, you can control the configuration parameters from php. Also here we see what php.
There is quick access to the Fast. CGI handler created by the installer. It is possible to add other versions of PHP and switch between them. We have not tested if it is possible to use PHP Manager to set different PHP versions on different virtual hosts. I think this and much more, such as to use different php.
Ruslan Yakushev from Microsoft. We just needed to add PHP version 5.
Now we can add PHP 5. C: \PHP. After adding, we see that IIS now uses a new version of PHP, and that PHP Manager created a new handler, which is used (we do not see it here), but we can check with phpinfo(), which PHP manager can dynamically generate for us (how- cool- it- is!).
Now it is time to look at PHP extensions (modules). I removed mysql and added both versions of the MS SQL driver sqlsrv and pdo_sqlsrv. I forgot to check if IIS sees our changes immediately.
I am used to executing “iisreset” after changing configuration. PHP Manager offers two pre- defined configuration options for error handling for development and production. When I changed the path to the error log, PHP Manager did not see my changes, and I had to restart the IIS. I really got used to the old fashioned way for a folder for uploaded files, session and logs and store them in PHP C: \tmp. No wonder our periodic scripts are in C: \etc. Options ‘Configure error reporting’ and ‘Set runtime limits’ are kept separately in PHP Manager for convenience only, as they all (except for the extension modules) are available from the ‘Manage all settings’ panel.
If you need to parse HTML files with PHP – create one more mapping by looking at parameters of existing PHP mapping you already have. Now we can try to connect to MS SQL with the driver only and via ADODB. First you need to make sure the server is configured to allow TCP/IP as well as port 1. Windows firewall. In my case it was not so. If you cannot connect from PHP, it is recommended to install SQLCMD and use it for testing. For example, here we will find the required version of SQLCMD.
I want to draw your attention to the fact that the new Microsoft driver returns datetime as PHP Date. Time: : object. But we use ADODB, which does this little trick converting this object into a string on line 7. Y- m- d\TH: i: s\Z"); Thus, returning us the string ’2.
T2. 3: 4. 2: 2. 2Z ‘instead of the usual ’2. Date. Time object//$this- > fields[$key] = $value- > format("Y- m- d\TH: i: s\Z"); //DSL Date. Time output format fix$this- > fields[$key]=$value- > format("Y- m- d H: i: s"); }}}Here is an example, where you can find connection and query snippets which use Microsoft driver directly and via ADODB.< ? B> Direct driver connection< /b> < BR> "; $connection. Info=array("UID"=> 'aws_user',"PWD"=> 'Q1w.
Database"=> "AWS_Database"). Connect using SQL Server Authentication. Info); if($conn===false){echo"Unable to connect.< /br> "; die(print_r( sqlsrv_errors(),true)); }. SELECT GETDATE() AS today"; $stmt= sqlsrv_query($conn,$tsql); if($stmt===false){echo"Error in executing query.< /br> "; die(print_r( sqlsrv_errors(),true)); }.
SQLSRV_FETCH_ASSOC); echo"Today is ".$row['today']- > format('Y- m- d H: i: s')."< /br> ". SERVER["DOCUMENT_ROOT"]."/include"); require_once("adodb. Q1w. 2e. 3r. 4t. 5"; $server="1. AWS_Database". echo"< B> ADODB MSSQL Native connection< /b> < BR> "; $ado. Connection= ADONew. Connection('mssqlnative'); //$ado.
Connection- > debug = true; $ado. Connection- > Connect($server,$user,$password,$database).
Connection- > Execute($tsql). Today is ".$rs- > fields['today']."< /br> "; $ado. Connection- > Close(); ?> In conclusion, we want to say that the Microsoft site provides a lot of useful information for running PHP on IIS and using Microsoft drivers to connect to MS SQL. For example, here you will find the entry to the forum PHP/IIS, and other useful links. Forums dedicated to PHP driver for MS SQL databases are located here.
I used them more- than- once. They are active and guys helped me a lot. Finally a couple of handy articles on how to configure PHP on IIS: - Enable Per- Site PHP Configuration on IIS 7 and IIS 6. Using Fast. CGI to Host PHP Applications on IIS- Using Fast. CGI to Host PHP Applications on IIS 6.
Igor. Print this post.