Integrating PHP with Microsoft IIS
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:
- Microsoft IIS from Microsoft Windows CD
- PHP (zip version). You can find it at www.php.net
If you have IIS and PHP installed on you computer, you can skip this part.
- 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.
- 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\".
Let's configure IIS.
- Open Windows Control Panel. Click Administrative Tools, then click Internet Information Services.
- Click the "+" sign beside your computer name, then click on the same sign beside the Web Sites folder.
- You will find the Default Web Site and you have to right-click on it and choose properties to start configuring you IIS.
- Click the Home Directory tab. Find the Configuration button and click it.
- On the Mapping tab, click the Add button.
- 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.
- In the extension textbox, you have to fillÂ itÂ with the PHP file extension which is .php. Click OK.
- 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.
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.
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.