Thursday, March 13, 2008

Setting up PHP on IIS 5 (XP 5.1)

1. Download both PHP and PECL (NOT the non-thread safe file) Windows zip packages from: http://www.php.net/downloads.php

2. Extract PHP zip into C:\PHP

3. Extract PECL zip into C:\PHP\ext (make sure you're not adding the PECL folder but rather the contants)

4. Create 3 subfloders in C:\PHP - sessions, upload, log

5. Create new file php.log in C:\PHP\log

6. Add ";C:\PHP" (without the quotes) to your Environment Variables.
  • Right-click "My Computer", select properties
  • Select the Advanced tab and click Environment Variables
  • In System Variables, select "Path" and click the Edit button
  • Paste ";C:\PHP" (without the quotes) to the end of the existing string

7. Add New "PHPRC" System Variable
  • From the Environment Variables window, click New under System Variables
    • Variable Name = PHPRC
    • Variable Path = C:\PHP

8. Add PHP mapping to IIS
  • From IIS mmc, right-click "Web Sites"
  • Click the "Home Directory" tab
  • Click the "Configuration" button
  • From the "Mappings" tab, click the "Add" button
    • Executable: c:\PHP\php5isapi.dll
    • Extension: .php


9. Configure PHP.ini
  • Copy php.ini-recommended and rename to php.ini
  • In php.ini replace the following:
    • extension_dir = "./" with extension_dir = "c:\PHP\ext"
    • session.save_path = "/tmp" with session.save_path = "c:\PHP\sessions"
    • upload_tmp_dir = with upload_tmp_dir = "c:\PHP\upload"
    • error_log = filename with error_log = "c:\PHP\log\php.log"
    • extension=php_mysql.dll with extension=php_mysql.dll

10. Restart IIS

11. Test
  • Create new web site in IIS
  • Create file in new web site: phpinfo.php with the following as content:
    <?php
    phpinfo();
    ?>
  • Open new file in browser. If config page loads, you're done.

No comments:

Post a Comment