5
0
0

Integrating PHP with Microsoft IIS

BogeymanviaBogeyman's Blog
September 24, 2008

PHP always identic with Apache web server. But, do you know that the other web servers can be used together with PHP as well as Apache? This short tutorial will show you how to use PHP alongside with Microsoft Internet Information Services (IIS).



Prepare the software


First, you have to prepare these software:

  1. Microsoft IIS from Microsoft Windows CD

  2. PHP (zip version). You can find it at www.php.net

Installation

If you have IIS and PHP installed on you computer, you can skip this part.

  1. Install IIS
  • Insert the Microsoft Windows CD.

  • Open Control Panel and choose Add or Remove Programs.

  • Click on Add/Remove Windows Components.

  • Give a check mark on Internet Information Services.

  • Click Next and follow the installation instruction until finish.



  1. Install PHP

  • Extract the zipped file to C:\php5.

  • Copy php.ini-dist to C:\Windows then rename it to php.ini.

  • Edit your php.ini and find this following line : extension_dir="./". Change it to extension_dir="C:\php5\ext\".
Configure your IIS

Let's configure IIS.

  1. Open Windows Control Panel. Click Administrative Tools, then click Internet Information Services.

  2. Click the "+" sign beside your computer name, then click on the same sign beside the Web Sites folder.

  3. You will find the Default Web Site and you have to right-click on it and choose properties to start configuring you IIS.

  4. Click the Home Directory tab. Find the Configuration button and click it.

  5. On the Mapping tab, click the Add button.

  6. Now, you are about adding the .php extension so the PHP file can be processed by IIS. In the executable textbox you have to point to the full path of the php5isapi.dll file location for parsing PHP file. You can click browse to find it. In this example, the location of php5isapi.dll is in C:\php5.

  7. In the extension textbox, you have to fill it with the PHP file extension which is .php. Click OK.

  8. Finish? Not yet. Back to the Default Web Site's properties window, click on Documents tab. Now you are about configuring the default page for IIS. Click Add and type index.php for the default document name. Click OK.

Testing

Create the phpinfo.php file which has simple content like this.







Save it in your web server directory (C:\Inetpub\wwwroot) and call it from your web browser.



More Options

If you want to use a database server, you have to activate the PHP extension to the related database server. For example if you want to use MySQL, you have to uncomment the line like this ;extension=php_mysql.dll. After that, don't forget to copy the libmysql.dll file from C:\php5 to C:\Windows\System32.



The same way can be applied if you want to use Oracle database server. First, you have to uncomment the line that says ;extension=php_oci8.dll. The next step is a little bit different. You have to copy oci.dll file from your Oracle Instant Client directory to C:\Windows\System32. You also have to set some environment variables such as PATH and NLS_LANG. You can see my previous tutorial about Connecting To Oracle 8 With PHP for further information.



Discussion

-