How to Set up PHP on IIS7.5 Windows Server 2008 r2 with FastCGI

91 篇文章 1 订阅
58 篇文章 0 订阅

With PHP being such a popular programming language for the web, it is important to understand how we can leverage our windows web server to run php. Below I will demonstrate how to install PHP 5.4 onto my brand new IIS7 web server. This server is running Windows 2008 r2 standard edition. A couple of disclaimers before I get started with the basic guide: You will need to adjust the paths in this guide suitable to your environment, I am using C: for my default website and S: (Secondary) drive for my program files (aka php installation). You will also need to make sure that you have the appropriate C++ runtime environment on your operating system. This is a fairly standard requirement so it is not included in this guide. Lastly, if you run into any problems or have question please feel free to reply to this thread or create your own and I will be more than happy to help you figure out what's going on (in my experience if you follow this guide and something isn't working it's a permission problem, or a php.ini configuration problem)

  • The first step to making sure you can use PHP on your IIS server it to make sure you have CGI enabled. This can be done from the Server Manager under the Roles section.
  • Next lets head out to [url="http://php.net/downloads.php
  • and select the Windows {Version} binaries and source link.
  • Next make sure you download the "Non Thread Safe" zip file of the version you want. You may also notice that it says VC9 x86, this indicates that you will need the x86 version of the c++ 2008 package on your machine in order for php to run.
  • You will then be presented with some sort of download menu, if your using a browser that supports it just go ahead and open the zip file.
  • After you have the zip file opened go ahead and select "Extract all files" near the top left corner of the window.
  • Now extract these files to wherever you want your php installation to be located. For me I have this on a secondary drive under Program Files. Following the extraction go ahead and open up that folder as we have some work to do in that directory before we're done.
  • In your PHP installation directory copy your php.ini-production (or development depending on what kind of sites you are putting up on this box).
  • Then paste this file back in and rename it to be "php.ini"
  • In your php.ini file make sure you have the following set:
    open_basedir ={YOUR IIS WEBSITES PATH HERE}
    cgi.fix_pathinfo=1
    fastcgi.impersonate=1
  • After this set up your extensions you wish to have enabled and configure the rest of your php.ini file to your liking. Save and close the file.
  • Next Open up the Internet Information Services (IIS) Manager.
  • Select the "Handler Mappings" for your server
  • Then click the "Add Module Mapping..." found in the top right corner of the Handler Mappings screen.
  • Then fill in the following information and click OK:
    Request path:

    *.php

    Module:

    FastCgiModule

    Executable (optional):

    {THE LOCATION OF YOUR PHP INSTALLATION}\php-cgi.exe

    Name:

    PHP via FastCGI

  • After you click OK you will be prompted: "Do you want to create a FastCGI application for this executable? Click 'Yes' to add the entry to the FastCGI collection and to enable this executable to run as a FastCGI application." to which you should click "Yes".
  • At this point you should have php running on your IIS server. To test, create a file called phpinfo.php in your default website directory (default is C:\inetpub\wwwroot\) and put the following code in the file and save it.
    <?php
    phpinfo();?>
  • After you have added that file open a web browser on the server and go to [url="http://localhost/phpinfo.php
  • and you should see your php information if php is working properly. If not revisit the steps above and try and find what you might have missed.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值