筆記不支援上傳圖片,記成文章了
首先 安裝IIS時,找到全球資訊網服務--應用程式開發功能,以下3項要勾選:CGI ISAPI擴充套件 IASPI篩選器
1.先安裝php
http://windows.php.net/download/
我裝是的phpstudy整合環境,用的裡面的php5.2
2.設定php.ini 拷貝php.ini-development,改名為php.ini,並進行如下修改
2.1 擴充套件外掛的路徑
; Directory in which the loadable extensions (modules) reside. extension_dir ="D:\phpStudy\php52\ext"
填入自己真實的PHP直譯器地址,以及後面跟著ext資料夾,這個裡面放的都是外掛
2.2 設定要引入哪些外掛
; Windows Extensions ; Note that ODBC support is built in, so no dll is needed for it. ; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5) ; extension folders as well as the separate PECL DLL download (PHP 5). ; Be sure to appropriately set the extension_dir directive. extension=php_bz2.dll extension=php_curl.dll ;extension=php_dba.dll ;extension=php_dbase.dll ;extension=php_fdf.dll extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_ifx.dll ;extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll extension=php_mbstring.dll ;extension=php_exif.dll extension=php_mcrypt.dll ;extension=php_mhash.dll ;extension=php_mime_magic.dll ;extension=php_ming.dll ;extension=php_msql.dll ;extension=php_mssql.dll extension=php_mysql.dll extension=php_mysqli.dll ;extension=php_oci8.dll ;extension=php_openssl.dll extension=php_pdo.dll ;extension=php_pdo_firebird.dll ;extension=php_pdo_mssql.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll ;extension=php_pdo_oci8.dll extension=php_pdo_odbc.dll ;extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_pspell.dll ;extension=php_shmop.dll ;extension=php_snmp.dll ;extension=php_soap.dll ;extension=php_sockets.dll extension=php_sqlite.dll ;extension=php_sybase_ct.dll ;extension=php_tidy.dll ;extension=php_xmlrpc.dll ;extension=php_xsl.dll extension=php_zip.dll ;extension=php_mongo.dl ;extension=php_sqlsrv.dll ;extension=php_pdo_sqlsrv.dll ;extension=php_ibm_db2.dll ;extension=memcache.dll
2.3 設定時區
[Date] ; Defines the default timezone used by the date functions date.timezone = PRC
改成
date.timezone = Asia/Shanghai
2.4 啟用fastcgi
; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate ; security tokens of the calling client. This allows IIS to define the ; security context that the request runs under. mod_fastcgi under Apache ; does not currently support this feature (03/17/2002) ; Set to 1 if running under IIS. Default is zero. fastcgi.impersonate = 1;
2.5 cgi相關設定pathinfo
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok ; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting ; this to 1 will cause PHP CGI to fix it's paths to conform to the spec. A setting ; of zero causes PHP to behave as before. Default is 1. You should fix your scripts ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED. cgi.fix_pathinfo=0
2.6 cgi相關設定redirect
; cgi.force_redirect is necessary to provide security running PHP as a CGI under ; most web servers. Left undefined, PHP turns this on by default. You can ; turn it off here AT YOUR OWN RISK ; **You CAN safely turn this off for IIS, in fact, you MUST.** cgi.force_redirect = 0
IIS 官網 https://www.iis.net 還說了開啟錯誤紀錄檔,我沒有開啟。
Set error_log="C:php_errors.log" This can help with troubleshooting.
這是官網的設定php說明
https://www.iis.net/learn/app...
微軟官方的技術資源庫中文相關檔案
https://technet.microsoft.com...
3.設定IIS,安裝IIS時,以下3項要勾選:CGI ISAPI擴充套件 IASPI篩選器
3.1 找到處理程式對映,新增模組對映
都點選確定之後,會彈出一個警告對話方塊,點選「是」就可以了,由於已經新增好了,這裡找到新增的模組截的圖
3.2 找到ISPAI和CGI限制,點右邊的新增。這裡截圖是新增好的
3.3 找到ISPAI篩選器,點選右邊的新增,這裡同樣是新增好的截圖
3.4 新增預設檔案
之後新建一個站點用以測試,在新增的站點根目錄下新建index.php,輸入<?php phpinfo(); ?>
儲存,接著瀏覽網站,會看到phpinfo資訊了