Win7下IIS安装PHP环境
Win7下IIS安裝PHP環境
Win7下是IIS7的版本,使用 FastCGI跑PHP,安裝過程記錄如下。安裝IIS7并打開CGI
? ? 在Windows7的控制面板-程序中“打開/關閉Windows功能”,在里面打開IIS,不要忘了打開IIS里的CGI(這個默認是不選的), 如下圖(直接用微軟的圖):?
點擊“確定”(OK),等待安裝完畢。
安裝PHP
在“http://windows.php.net/download/”里下載,我下的是php-5.6.9-Win32-VC11-x86,5.3.1的。解壓到隨便哪個目錄里,我放到E:\php目錄下,然后配置方式如下:
1、把目錄下的php.ini-development改為php.ini,用記事本打開;
2、fastcgi.impersonate=1(并把行首的分號刪掉,下同)
3、 cgi.fix_pathinfo=1
4、cgi.force_redirect=0
5、extension_dir="./ext"
6、打開需要的擴展,比如extension=php_mysql.dll
(有的ext目錄里沒有php_mssql.dll這個文件,可以暫時不打開php_mysql.dll,這樣就能順利通過。)
7、更改時區,date.timezone=?Asia/Shanghai ? ?詳情參考:http://www.php.net/manual/en/timezones.asia.php
以上幾點做完,可以在“開始-運行-cmd”下試著運行E:\php\php -info和E:\php\php -v,正常來說-info參數可以看到php的參數信息,而-v參數可以看到php的版本信息,如dll文件不存在的擴展打開了的話,-v時會有提示。
配置IIS
下面,回到IIS上,打開IIS控制臺,在左邊樹中選最頂級結點,也就是你的電腦名,然后在中間(功能視圖)里打開“Handler Mappings”(中文叫“處理程序映射”),如下圖:
?
打開之后在最右邊點“添加模塊映射”(Add Module Mapping),照下圖添加信息:
?
請求路徑:*.php
模塊:FastCgiModule
可執行文件:E:\php\php-cgi.exe(選的時候把類型由dll改成exe)
名稱:PHP via FastCGI
然后OK,再然后Yes(如圖)
?
重啟IIS!?
到此,就可以enjoy了,怎么試?
做一個test.php文件,里面的內容是<?php phpinfo(); ?>,然后在瀏覽器里打localhost/..../text.php。
(這一界面我用我自己的圖,以證明我真配成了)
注意事項:
1、安裝后入出現FastCGI進程退出或缺少MSVCR110.dll的,
? ? ? ? ?則需要下載Visual C++ Redistributable Package 2012
下載地址:http://www.microsoft.com/zh-CN/download/details.aspx?id=30679
2、PHP Manager
在IIS7上安裝php有一個非常方便的IIS插件,PHP Manager for IIS,幾乎所有問題都能幫你搞定,只需要將php解壓縮到一個位置,然后通過它選擇一下php-cig.exe文件就ok,php.ini自動幫你配置,處理程序映射也自動幫你設置,而且還可以非常方便地切換多個php版本。 ? ? ?
官方說明文檔?如下
Installation
From the?Downloads?page select the installation package that is appropriate for your target machine. Download and run the installer, which will install and register PHP Manager's binaries with IIS. Note that only IIS versions 7.0 and above are supported. After installation is complete, launch the IIS Manager and find the "PHP Manager" feature:
When opened, the "PHP Manager" feature provides a configuration overview for the PHP installation that is registered with IIS and is currently active. If no PHP is registered with IIS, then the only action that can be performed is the registation of a new PHP version.
Registering PHP with IIS
To register a new PHP version with IIS, first you need to download the zip archive with PHP binaries fromhttp://windows.php.net/?and then extract the files from it into a folder of your choice. Note that you can also install PHP by using?Web Platform Installer?or the Windows installer from?http://windows.php.net/?- the PHP Manager can be used to manage those PHP installations as well.
Click on "Register new PHP version" task and then provide the full path to the location of the main php executable file:?php-cgi.exe:
After clicking OK the new PHP version will be registered with IIS and will become active. This means that all the sites on this IIS server by default will use this PHP version.
Validating existing PHP installations and fixing configuration issues
In order for PHP to run properly on IIS there is a set of recommended settings that need to be configured in IIS and PHP. PHP Manager checks if all of the recommended settings are configured correctly. If some settings are not configured properly then you can use PHP Manager to fix those settings.
When some configuration settings are configured incorrectly you will see a warning message when you open PHP Manager:
After clicking on "View Recommendations" link you can see all the configuration issues that exist in your PHP installation. You can review each issue description and the recommended corrective action. You can also select which configuration issues you want to be fixed:
Switching between PHP versions
After multiple PHP versions have been registered with IIS, you can use PHP Manager to easily switch between the versions on a server, site and application levels. This means that you can configure some IIS sites to use one PHP version, while other sites use different version. Also, you can configure separate applications within a web site to use different PHP versions.
Note: When switching the PHP versions on any level except server level, the PHP Manager will make a local copy of all IIS Handlers on that level. This means that if later you make any changes to handler mappings?on an upper configuration level, that won't take effect on this configuration level. You can easily determine if the PHP handler is defined locally versus being inherited from an upper configuration level by checking the?information on?PHP Manager main feature page:
Checking phpinfo() output
phpinfo() function in PHP provides very detailed information about all aspects of PHP runtime configuration. To check the phpinfo() output from within PHP Manager use the "Check phpinfo()" task.
Configuring Error Reporting
You can use PHP Manager to configure error reporting level in PHP. If IIS is used on a development machine then you may want to use verbose error reporting in order to see all the errors, warnings and notices from your PHP application right away. If IIS is used as a production server, then error reporting level is less verbose and errors are logged in a log file, but never communicated to HTTP client.
?
Configuring Runtime Limits
Various timeouts and limits can be configured in the "PHP Runtime Limits" page:
?
Configuring All PHP Settings
All existing PHP settings can be added, removed and modified in the "PHP Settings" page.
Enabling or Disabling PHP Extensions
PHP extensions can be enabled or disabled in the "PHP Extensions" page:
Last edited?Jun 28, 2011 at 4:42 AM?by?ruslany, version 3
總結
以上是生活随笔為你收集整理的Win7下IIS安装PHP环境的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学习 Bootstrap 5 之 For
- 下一篇: php中表格标记是,HTML标记语言——