กรณีศึกษาการ Interoperability Software ที่พัฒนาโดย PHP กับ IIS7 บน Windows Web Server
กรณีศึกษาการ Interoperability Software ที่พัฒนาโดย PHP กับ IIS7 บน Windows Web Server
Agenda
PHP on Windows IIS 7.0 Core Architecture FastCGI on IIS 7.0 Best practices and patterns Demo Web Application (e-Office)
PHP on Windows
Whats the difference between PHP on Windows and Linux Why I run PHP on Windows !
PHPBB2
VBulletin
VBPortal
cPanel
Drupal
e107
MD-Pro
MyPHPNuke
PHPWebSite
TikiWiki
Typo3
Xaraya
b2Evolution
bBlog
Serendipity
WordPress
TextPattern
OSCommerce
OSCNuke
Zen Cart
eGroupWare
phpGroupWare
Site@School
ATutor
Moodle
Segue
Coppermine
QwikiWikki
SugarCRM
WebCalendar
FUTURE TECHNOLOGIES
MS Excel
PowerPoint
SharePoint
SQL RS
Business Manager
ISA Server
MS FrontPage
MS Project
MS CMS
SQL AS
Virtual Earth
Data Analyzer
MS InfoPath
Exchange Server
SQL NS
Messenger
MS Mobile
Live Meeting
MS Visio
Commerce Server
Project Server
MapPoint
Tablet PC
MS OneNote
MS Word
MS CRM
MOM
App Center
MS Starter Kits
IIS 6/7
Axapta
Navision
Info Bridge
Media Center
ADAM
MSMQ
Great Plains
Retail Management
WSH
Info Card
Authorization Manager
DirectX
WinFX
Operations Manager
Windows Mobile
MS Solomon
VBA / VSA
ActiveX
Windows Workflow
MS Enterprise Reporting
XML-WS WSE
Application Center
MSN Search
Hosted Controls
Windows Embedded
Vista Longhorn
PHP on Windows
PHP Developers work on Windows machines anyway. PHP is PHP is PHP. Zend offers the Winabler. Other 3rd parties offer.
Phalanger = Managed Code PHP http://www.php-compiler.net/
PHP On Windows
Whats the problem anyway.
CGI on Windows ? The PHP ISAPI Extension Will it get fixed ?
PHP on Windows
FASTCGI ! PHP on IIS 6
PHP Versions. Why choose ?
PHP on IIS 7
New application context ?
Inetinfo.exe Lsass.exe Windows Authentication SSL metabase NNTP Service IIS Admin Service
Svchost.exe
FTP Service
SMTP Service
User Kernel
HTTPAPI
Inetinfo.exe Lsass.exe Windows Authentication SSL metabase NNTP Service IIS Admin Service
SMTP Service
User Kernel
Winsock
aspnet_isapi.dll
static file ISAPI exts
IHttpModule Events url map begin req authc req authz req
cgi
Server is monolithic: cant extend core features cant remove core features cant add features Feature duplication between IIS and ASP.NET.
resolve cache
handler map handler exec
end req
update req cache rel req state
Features limited due to position in pipeline. ASP.NET functionality not applied to IIS content types.
w3svc
url map
authc req
log
IHttpHandlers
Trace.axd
PageHandler
http.sys
IIS7 Architecture
W3wp.exe
Native or Managed Handlers
Native iiscore
Unified request processing pipeline. All services provided by selfcontained modules Modules can be managed or native All services can apply to all requests
static Isapi Integrated pipeline cgi begin req exts end Native file IHttpModule authc req log Module Determine handler other other
native modules update cache release state execute handler authz req managed modules
Svchost.exe
resolve cache
end req
update req cache rel req state
url map
log
WAS w3svc
basic auth
authc req
digest auth
role IHttpHandlers
Trace.axd
windows auth
Pre-proc headers
authenticate
begin
http.sys Tcpip.sys
A full description of all IIS7 modules is covered in the following tables, they have been broken down in to groups based on functionality:
Caching Modules Compression Modules Content Modules Authentication Modules Security Modules Logging & Error Modules Diagnostics Modules Development Modules IIS 7.0 Managed Modules
Development technologies offered as to execute code from that platform Implements Managed Interfaces, etc.
Module Name IsapiModule IsapiFilterModule CgiModule FastCgiModule Description Implements ISAPI Extension Server Functionality Implements ISAPI filter functionality Resource Location Inetsrv\isapi.dll Inetsrv\filter.dll
Executes CGI processes to build response Inetsrv\cgi.dll output. Enables Fast CGI application frameworks like PHP be hosted on the IIS web server. Implements configuration validation, e.g. if an application runs in integrated mode but has handlers or modules declared in the system.web section. Connects the IIS core pipeline with the ASP.NET runtime and bridge between native and managed code in IIS 7.0 inetsrv\iisfcgi.dll
ConfigurationValid ationModule
inetsrv\validcfg.dll
ManagedEngine
..\Framework\v2.0.50727\webengine.dll
Managed
- or -
ASP.NET
Static
Compress
Cache
Logging
Anon
Basic
FastCGI
ASP
Errors
ISAPI
Tracing
Forms
UrlAuth
Integrated pipeline
Unified request processing pipeline for both native and managed (ASP.NET) modules
All modules can provide services for all content types.
You can use ASP.NET forms authentication and url authorization to protect all content on the server You can develop an ASP.NET module to append custom headers to static file requests.
IIS7 Modularity
Publishing Security
AnonymousAuthentication BasicAuthentication DigestAuthentication WindowsAuthentication UrlAuthorization CertificateMapping ADCertificateMapping RequestFiltering IPRestriction CGI FastCGI ServerSideIncludes ASP ASP.Net ODBCLogging LoggingLibraries RequestMonitor HttpTracing
Application Development
.NET Extensibility ISAPIFilter ISAPIExtension
Performance
StaticCompression DynamicCompression
CustomLogging
Management
Management Console Management Scripting
Invokes a process for each request. Advantages Easy to Configure Stable Execution Disadvantages Slow due to I/O Overhead of Process Creation
Loaded as extension in process. Advantages Better Performance Disadvantages Many PHP Applications are not Thread-Safe
Extension to CGI allowing reuse of a process. Advantages Easy to Configure Faster than CGI More stable than PHP on ISAPI Can run nonthread-safe versions of PHP
php-cgi.exe
FastCGI Handler
1 : Receiving requests in IIS WP 2 : Queieing requests 3 : Dispacthing and receiving response from FastCGI process 4 : Creating one or more FastCGI App Process
FastCGI Handler
Mapping the FastCGI handler to process requests Processing all URLs in a directory Response buffering 64 bit support Process Management
Create configured FastCGI application processes when needed. Maintain a connection with each FastCGI application process during its lifetime Monitor health of FastCGI application processes Periodically recycle FastCGI processes Detect when FastCGI processes exited / crashed, and recover gracefully Terminate FastCGI processes
FastCGI Roles
Responder
The fundamental FastCGI role Functionally identical to CGI Supported by all FastCGI capable servers
Authorizer
Provides a means of controlling access to a site, a page, or something in between Typically, this involves some form of authentication, but this isnt required It has server dependent significance
Filter
Allows processing of a file before it is sent Intended to support: Format conversions Dynamic documents (embedded code) Applying templates: e.g. headers, footers, backgrounds Conceptually this could support dynamic content chaining, but without server support has limited utility
Advanced diagnostics
PHP users who deployed to Apache in the past will be more comfortable with IIS7 than IIS6 due to the new configuration system and modular architecture.
applicationHost.config
Central configuration file for the server contains system wide configuration settings.
web.config
web.config
Distributed configuration files contain overrides and local site and application settings.
Web application
e-Office
demo
Open Source
PHP IIS7 Module Fast CGI server manager Role Web Server Add Role Service
CGI Next
Install
Install CGI
Module Mapping Request Path : *.php Module : FastCGIModule Executable : php-cgi.exe Name : php
FastCGI
PHP
IIS7 FastCGI
Fast CGI + Caching
Fast CGI
Reference
FastCGI on IIS 7.0 by Risman Adnan PHP on Microsoft 7.0 by Risman Adnan
http://geeks.netindonesia.net/blogs/risman