Wednesday, December 21, 2011

PHP on IIS

IIS Installation
Go to Start -> Control Panel -> Add Remove Program -> Add and Remove components -> Enable IIS -> Restart Machine
 
PHP INSTALLATION
1) Download PHP from "http://www.php.net/downloads.php" 2) Create a folder named php on c drive 3) Extract all of the files from the downloaded zip file into C:\PHP 5) Add the PHP directory path to the environment variables PATH
 
How to add environment variable PATH 1) Right-Click on My computer and choose "properties". 2) select the Advanced tab 3) click the "Environment Variables" button (There are two sections in the Environment Variables    window, User Variable and System Variables. We will be using System Variables. Scroll down until you find the variable PATH. Highlight and click on edit button,add the php path to the end of the line (C:\PHP)
 4) restart the machine. 
 
php.ini configuration
Rename php.ini-recommended file to php.ini in C:\PHP folder
 
Php.ini changes 
1) doc_root = C:\inetpub\wwwroot
2) cgi.force_redirect = 0
 
IIS_PHP Integration  
1) Open IIS ( start-controlpanel-performance and maintenance-administrative tools
2) Right click on Default website 
3) select properties 
4) Click on configuration 
5) Click Add 
6) Set "executable" to C:\PHP\php5isapi.dll 
7) Set "extension" to .php 
8) Click Apply, then OK 
9) Under ISAPI Filters ;Click "Add" 
10) Set Filter Name to PHP 
11) Set Executable to C:\PHP\php5isapi.dll 
12) Restart the Web Server ( right click on local computer select all tasks the click on IIS restart)
 
Testing 
1) Go to C:\inetpub\wwwroot 
2) create a file and type <?php echo phpinfo(); ?> ( the extension should be .php
3) Open your web browser and type: http://localhost/phpnfo.php
 
For the database connectivty you have to copy the ntwdblib.dll file on the system32 folder.