Results 1 to 9 of 9

Thread: PHP on IIS Server

  1. #1
    Mentor
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    1,159
    http://www.peterguy.com/php/install_IIS6.txt
    Last changed 11:33 AM 12/27/2004
    questions/props/corrections/etc... > peter@peterguy.com
    flames > /dev/null ;-)

    How to install PHP 5.x on Windows Server 2003 with IIS 6.

    A detailed and hopefully helpful step-by-step guide, based on my experience.

    YMMV.

    The lines beginning with dashes are the steps, the stuff in between is more detail should you need it.

    I'm hoping to convert this to an html-based guide that's prettier, but my time is limited.

    This guide does not cover initial setup of IIS, or configuration of a Windows 2003 server in general.

    This guide is divided into 3 main steps:
    1. install PHP (the easiest step, like having a baby is to raising a child)
    2. Configure PHP (lots of php.ini editing)
    3. Configure IIS (lots of pointing and clicking in IIS Manager)


    So, let's get into it...


    *************************
    1. Install PHP
    *************************


    1.1 Unzip latest version of PHP to C:\PHP (I used 5.0.2)

    Download the latest zipped distribution of PHP from php.net, not the Windows installer.
    You can pick any drive, and any folder, but the recommendation is to put all the PHP stuff in a folder just off of the root drive, like C:\PHP, and this guide will follow that recommendation.


    1.2 Rename/copy php.ini-recommended to php.ini

    In your PHP directory, you'll find a couple of php.ini-* files. They are pre-configured settings for a PHP install that you can use as an initial setup. php.ini-recommended is the most secure, hence, the recommended one; just rename it to php.ini, overwriting any existing php.ini.


    *************************
    2. Configure PHP, mainly editing php.ini
    *************************


    2.1 Uncomment "cgi.force_redirect" in php.ini and set equal to 0

    *** This is a very important step, don't neglect it. ***


    2.2 Download browscap.ini (I got it from http://www.garykeith.com/browsers/downloads.asp - php_browscap.ini) to C:\PHP\extras\browscap.ini
    2.3- Uncomment and edit the browscap variable in php.ini to point to C:\PHP\extras\browscap.ini

    You don't _have_ to install a browscap file, it's just for those who want to use the browser identification features of PHP. It's pretty straightforward: download php_browscap.ini from the above website to the extras directory under your PHP install directory, and change the variable in php.ini to point to the browscap file.


    2.4 Grant IUSR Read and Execute, and Read permissions on php.ini

    This is so that the unauthenticated Internet User (under which PHP will run in a website) will have read access to the configuration file.
    Right-click on your newly-created php.ini file, then click on "Properties" in the list that pops up. This will open a dialog box with several tabs. One of the tabs is named "Security". Click on it. This tab shows a list of users who have permission to access the file. Click on the "Add" button, then enter in the rather large text box, "IUSR_<SERVERNAME>". Click on "Check Names" to have it find the user for you. If it can&#39;t find the username, a "Name Not Found" dialog box will display. In that case, "Cancel" the "Name Not Found" dialog, then click the "Advanced" button. This will open another dialog, where you&#39;ll click on the "Find Now" button, then scroll through the list of "Search results" to find the Internet Guest account (Probably displayed as IUSR_<SERVERNAME>). If you can&#39;t find the
    Internet Guest account, then make sure IIS is installed and enabled, which is a whole &#39;nother subject. :-)
    Once you find the Internet Guest Account, "OK" your way out of all dialogs. The default permissions are Read and Execute, and Read. You can probably uncheck the Read and Execute checkbox, although I left the default permissions.


    2.5 Create a session state directory, grant IUSR full control to it, and point "session.save_path" in php.ini to it.

    If you need to use PHP sessions, be sure to uncomment and change session.save_path to point to a valid directory somewhere to which IUSR has full control permissions. I created a "C:\PHP\Sessions" directory. I haven&#39;t explicitly tested this yet, I&#39;m following the directions of others.


    2.6 set "extension_dir" in php.ini to "C:\PHP\ext"
    2.7 Uncomment the desired extensions in php.ini (search for "extension=")
    2.8 Do one of two things:
    a. Copy all non-php dll files from C:\PHP to C:\Windows\System32 (or somewhere else in the server&#39;s PATH)
    OR
    b. Add "C:\PHP" to the server&#39;s PATH environment variable
    - right-click on My Computer, choose Properties
    - flip to the Advanced tab
    - click the Environment Variables button
    - Double-click the Path variable in the list of System variables.
    - Either add "C:\PHP;" to the beginning, or ";C:\PHP" to the end.
    - Re-boot the server for it to take effect.
    2.9 If you&#39;re going to use MySQL 4.1.5 or later, add the line, "extension=php_mysqli.dll" to the ini file, right after "extension=php_mysql.dll". As a side note, phpBB2 does not work with MySQL 4.1.x or PHP 5.x.

    If you want to use php extensions, you&#39;ll have to change the value of extension_dir in php.ini to be <PHP install dir>\ext (for PHP 5) and uncomment the applicable "extension=..." lines, then place the helper library files somewhere in the server&#39;s PATH, either by copying them, or modifying the PATH. I couldn&#39;t get some of the extensions to work, but most of them did.
    The MySQL connector has to be mysqli for MySQL 4.1.5 or later.


    2.10 Add to the registry HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath = C:\PHP

    This is so that PHP can find its configuration file. To make it easy on you, modify the following text between the dashes so that "C:\\PHP" is the directory in which you&#39;ve unzipped PHP, then copy the text (sans dashes) and paste into a new text file (anywhere, the Desktop is a good place to create it). Rename the file to "inifilepath.reg", then double-click on it, click "Yes" to the confirmation dialog, and the value will be in place. You can then delete inifilepath.reg.
    ---------------------------------------------------------
    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
    "IniFilePath"="C:\\PHP"
    ---------------------------------------------------------


    *************************
    3. Configure IIS
    For the rest of the steps, open IIS Manager (Start->Control Panel->Administrative Tools->Internet Information Services (IIS) Manager).
    *************************

    3.1 Add and allow the PHP ISAPI Extension to IIS Web Service Extensions: C:\PHP\php5isapi.dll

    When you open IIS Manager, it should connect to the local computer automatically. Expand the local computer in the left pane, then click on "Web Service Extensions" in the left pane.
    In the right pane, now, click the blue underlined text, "Add a new Web service extension...". Enter "PHP ISAPI Extension" as the "Extension name", then click the "Add..." button and browse to the php5isapi.dll file in your PHP install directory.
    There are two ways to setup PHP for the web: ISAPI and CGI. ISAPI is typically more efficient and secure. If you want to add the CGI extension, in addition to or instead of the ISAPI, repeat the above, but enter "PHP CGI Extension" as the "Extension name", and browse to php-cgi.exe in your PHP install directory for the "Required files".
    Once you&#39;ve named it appropriately and chosen the desired file, check the "Set extension status to Allowed" checkbox and click "OK".


    The following two steps are suggested to apply to the "Web Sites" root folder in IIS Manager, but they can be applied to individual sites, instead. When applying changes to "Web Sites", note that a dialog might come up asking if you want to apply changes to a list of specific websites, too. Note that the listed sites will be ones that have overridden any default values, so be careful about applying changes to them. Especially be careful of applying changes to the Microsoft SharePoint Administration site (thus speaks painful experience).


    3.2 Right-click on "Web Sites", goto Properties->Home Directory->Configuration...->Application Extensions, add a new extension: .php using C:\PHP\php5isapi.dll; allow GET,POST,HEAD. This will apply to every website.

    This sets up IIS to actually respond to requests for php files. "Web Sites" is a "folder" in the left pane of IIS Manager. php5isapi.dll will be in your PHP install directory. Replace php5isapi.dll with php-cgi.exe if you chose the CGI extension.


    3.3 Turn on scripting permissions for your websites

    Right-click on "Web Sites", goto Properties->Home Directory.
    Change the "Execute permissions" dropdown to "Scripts only".


    You made it, configuration is all done!


    3.4a Restart IIS

    Right-click the local computer in the left pane of IIS Manager, click on All Tasks->Restart IIS...->OK

    *** OR ***

    3.4b Reboot server

    Only if you modified the server&#39;s PATH environment variable for the extensions and haven&#39;t rebooted yet.


    *************************
    4. Test your setup
    *************************

    4.1 Create a new file named test.php in one of the websites containing the single line below:
    <? phpinfo(); ?>

    Expand the "Web Sites" folder in the left pane of IIS Manager to see a list of existing websites. Right-click->Properties->Home Directory->Local Path will show you where the website root directory is.

    4.2 Point browser there to test.

    *** NOTE ***
    If you uncommented extensions, be sure to test this from the server&#39;s console, not another computer, or even Terminal Services. Some of the extensions don&#39;t work, and an error dialog will pop up on the server console telling which one didn&#39;t work. You have to be able to click "OK" to the dialog for the page to finish loading. Take note of the extension that didn&#39;t work, click "OK", and then comment out the extension in php.ini until you can figure out how to get it to work.

  2. #2
    Senior Member
    Join Date
    Jan 2005
    Posts
    399
    Why do you write so much! :lol:

  3. #3
    Mentor
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    1,159
    um, I copy so much :lol:

  4. #4
    Senior Member
    Join Date
    Jan 2005
    Posts
    399
    Oh, ok. Your so lazy. :lol:

  5. #5
    Senior Member
    Join Date
    Jan 2005
    Location
    Neer Springfield, MA
    Posts
    443
    i call copy+paste smart, not lazy!
    "If you enjoy what you do, you&#39;ll never work another day in your life."

    My man confucius said it well :D

    Why is my signature text blue I did not make it like that??

  6. #6

  7. #7
    Mentor
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    1,159
    FoxServ is an Apache / mySQL / PHP installer package for Windows and Linux. Unlike NuShpere or PHPTriad, FoxServ features the latest version of all included pacakges, user defined configuration during installation, PHP as a module, PEAR, and the Zend Opt
    That, my friend, shall come in handy because I wanted to install mysql on my linux box and was having hard time going abouts putting in php/mysql compile. Thanks for the link.

  8. #8

  9. #9
    Senior Member
    Join Date
    Jan 2005
    Posts
    399
    I smell too much geek. Nah, just kidding. Good find SauceE.

Similar Threads

  1. How To Make A Dedicated File Server Or Web Server
    By beezlebubsbum in forum Linux - General Topics
    Replies: 11
    Last Post: 02-22-2009, 01:12 AM
  2. Moving a server to another part of network and still keeping it as a server
    By paolopunzalan in forum Linux - Hardware, Networking & Security
    Replies: 2
    Last Post: 07-29-2007, 09:38 AM
  3. Set Up SQL Server with Proxy Server
    By regix in forum Windows - General Topics
    Replies: 0
    Last Post: 01-04-2005, 03:18 AM
  4. ISA Server on Windows Server 2003
    By regix in forum Windows - General Topics
    Replies: 0
    Last Post: 01-01-2005, 09:49 PM
  5. Use Cluster Server to create a virtual server
    By regix in forum Windows - General Topics
    Replies: 0
    Last Post: 01-01-2005, 09:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •