PHP在II7安裝指南

來源:互聯網
上載者:User

參考文檔:

Using FastCGI to Host PHP Applications on IIS 7.0

一、PHP的安裝

1、下載並安裝程式

PHP 5.2.8 Non-thread-safe zip package

the update for FastCGI module

Administration Pack for IIS 7.0

Win2008下的IIS7與PHP相關問題

2、配置php.ini

把C:\PHP\php.ini-recommended 複製成php.ini,然後修改檔案:

fastcgi.impersonate = 1
cgi.fix_pathinfo=1
cgi.force_redirect = 0
open_basedir ="G:\Projects_PHP"   
extension_dir = "c:\php\ext" ;extension_dir = "./"
extension=php_mssql.dll
extension=php_mysql.dll

extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mcrypt.dll
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_mysql.dll

 其中open_basedir表示網站所在的包含目錄,你也可以指定為"G:\",這樣只要在G盤下的網站都可以在安全範圍之內

#為了使用session需要添加設定 session.save_path = "c:\php\tmp" 並建立目錄tmp

#extension_dir = "c:\php\ext"

3、配置IIS

IIS根-->Handler Mappings-->

    Request path: *.php
    Module: FastCgiModule
    Executable: "C:\PHP\php-cgi.exe"
    Name: PHP via FastCGI

IIS根-->FastCGI settings-->Edit... --> Edit FastCGI application-->instanceMaxRequest=10000

                                                  --> EnvironmentVariables --> PHP_FCGI_MAX_REQUESTS=10000

4、推薦的安全配置(僅供參考)

    allow_url_fopen=Off
    allow_url_include=Off
    register_globals=Off
    open_basedir="c:"inetpub""
    safe_mode=Off
    safe_mode_gid=Off
    max_execution_time=30
    max_input_time=60
    memory_limit=16M
    upload_max_filesize=2M
    post_max_size=8M
    max_input_nesting_levels=64
    display_errors=Off
    log_errors=On
    error_log="C:"path"of"your"choice"
    fastcgi.logging=0
    expose_php=Off

5、獨立配置

參考:http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/

中的"Per-site PHP process pools"和"Specifying php.ini location"

A、IIS根-->FastCGI Settings-->Add Appliction....-->fullPath="C:\PHP\php-cgi.exe"

                                                                           arguments="-d open_basedir=G:\Projects_PHP\Samples\PHP_Hello2"

查看:C:\windows\system32\inetsrv\config\applicationHost.config可見有如下配置:

<fastCgi>
 <application fullPath="C:\PHP\php-cgi.exe" instanceMaxRequests="10000">
  <environmentVariables>
    <environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />
   </environmentVariables>
  </application>
  <application fullPath="C:\PHP\php-cgi.exe"
arguments="-d open_basedir=G:\Projects_PHP\Samples\PHP_Hello2" maxInstances="4" idleTimeout="300" activityTimeout="30" requestTimeout="90"

instanceMaxRequests="200" protocol="NamedPipe" queueLength="1000" flushNamedPipe="false"
rapidFailsPerMinute="10" />

</fastCgi>

 

B、修改網站的web.config

<?xml version="1.0"?>
<configuration>
<system.webServer>
    <handlers accessPolicy="Read, Script"> 
        <remove name="PHP via FastCGI" />
        <add name="PHP via FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe|-d open_basedir=G:\Projects_PHP\Samples\PHP_Hello2" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
</system.webServer>
</configuration>

 

6、配置環境變數

例如安裝目錄在c:\php

配置Path的變數添加C:\PHP\;

7、安裝URL Rewrite Module

下載rewrite_x86_rtw.msi 

參考:URL Rewrite Module Using URL Rewrite Module URL Rewrite Module Configuration Reference 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.