PHP & Windows Jan Burkl System Engineer, Zend Technologies © All rights reserved. Zend Technologies, Inc. Wer bin ich? ● Jan Burkl ▶ ● PHP Entwickler seit 2001 ▶ ● Projektarbeit Bei Zend seit 2006 ▶ ● [email protected] System Engineer Zend Certified Engineer ▶ PHP 5 ▶ Zend Framework © All rights reserved. Zend Technologies, Inc. Agenda ● Geschichte & Background ● Optimierungen ● Zend Server unter Windows ● SQL Server © All rights reserved. Zend Technologies, Inc. Aktuell ● Stand 03.08.2010 ● PHP 5.3.3 ● PHP 5.2.14 ● http://windows.php.net/download/ © All rights reserved. Zend Technologies, Inc. Geschichte ● ● ● Oktober 2000 ▶ PHP 3.0.17 (Thread Safe) auf Windows (Multi-Threaded-Architektur) ▶ CGI: stabil, aber laaaaangsam (wg. Multi-Process-Modell, php.ini) ▶ ISAPI Modul für IIS: schneller, aber Crashes Performance ▶ Opcode Caches: Z.B. eAccelerator (Thread Safe) ▶ FastCGI – wenig/keine Inkompatibilität zu PHP Extensions PHP 5.2.1 ▶ ● Non Thread Safe (NTS) – kein Warten auf Thread Synchronisation FastCGI Handler von Microsoft ▶ FastCGI + NTS = Performance Boost © All rights reserved. Zend Technologies, Inc. Background ● Microsoft und Zend haben eine enge Partnerschaft ▶ ● ● Oktober 2006 Unternehmen arbeiten gemeinsam an der Verbesserung von PHP unter Windows PHP auf Windows ist schneller, sicherer und skaliert besser © All rights reserved. Zend Technologies, Inc. PHP unter Windows „Wir sind uns bewusst, dass PHP nicht immer problemlos auf der Windows-Plattform lief, deshalb haben wir Windows Server dahingehend optimiert, dass Ihre PHP-Anwendungen von einer neuen Komponente unterstützt werden: FastCGI. FastCGI arbeitet als Interface zwischen der PHP Engine und IIS und gewährleistet, dass PHP schneller läuft als mit CGI und viel zuverlässiger als PHP ISAPI.“ Quelle: http://www.microsoft.com/web/platform/phponwindows.aspx © All rights reserved. Zend Technologies, Inc. Technologie Partnerschaft ● Signifikante technische Fortschritte: ▶ ▶ PHP ist schneller und stabiler – alle Verbesserungen fließen zur Community zurück ▶ Server 2003, 2008, Vista, Win 7 ▶ SQL Server Treiber für PHP ▶ FastCGI Implementierung für IIS http://php.iis.net/ © All rights reserved. Zend Technologies, Inc. PHP optimiert für Windows • PHP 5.3 wurde für Windows optimiert • Performance Optimierungen • POSIX (Schnittstelle zwischen Applikation und dem Betriebssystem) Aufrufe zu nativen Win32 API’s geändert • Viele Windows-spezifische und FastCGI-spezifische Performance Verbesserungen 60+ Windows-spezifische Bugs gefixed • • Non-thread-safe Builds für maximale Performance mit IIS FastCGI © All rights reserved. Zend Technologies, Inc. Top Servers Across the Million Busiest Sites Developer May 2010 Percent June 2010 Percent Change Apache 664,186 66.82% 662,169 66.61% -0.21 Microsoft 167,740 16.87% 169,418 17.04% 0.17 nginx 48,598 4.89% 49,530 4.98% 0.09 Google 19,367 1.95% 19,425 1.95% 0.01 Quelle: http://news.netcraft.com/archives/2010/06/16/june-2010-web-server-survey.html#more-2249 © All rights reserved. Zend Technologies, Inc. Zend Server © All rights reserved. Zend Technologies, Inc. Zend Server - Web Application Server ● verbesserte PHP Applikationsperformance ● Application Monitoring und Diagnostik ● ● Produktionsfähiger PHP Stack inklusive Zend Framework technischer Support, Software Updates und Security Hotfixes ● Zend Studio Integration für vereinfachtes Debugging ● http://www.zend.com/de/products/server/downloads © All rights reserved. Zend Technologies, Inc. Installation Zend Server ● ● Native Installationsroutine PHP 5.2 ▶ ▶ ▶ ● Kein End-Of-Life für Zend Server mit PHP 5.2! VC8 PHP 5.3 ▶ © All rights reserved. Zend Technologies, Inc. PHP 5.2.14 „release marks the end of the active support for PHP 5.2” VC9 Kleiner Performance Test… ● Zend Server vs. XAMPP ▶ Zend Controller ▶ Zend Server: PHP 5.3.2 ▶ XAMPP: PHP 5.3.1 ▶ Stand: 02.08.2010 © All rights reserved. Zend Technologies, Inc. Zusammenfassung ● Performancegewinn durch ▶ FastCGI ▶ Optimizer+ (Byte-Code-Acceleration / Opcode-Cache) ▶ Page Cache ▶ Data Cache Demo… © All rights reserved. Zend Technologies, Inc. Konfiguration © All rights reserved. Zend Technologies, Inc. FastCGI ● http://files.zend.com/help/ZendServer/configuring_iis_timeouts.htm ● IIS-Konfiguration ● XML (IIS 7): ▶ C:\Windows\System32\inetsrv\config\applicationHost.config <fastCgi> <application fullPath="E:\Zend\ZendServer\bin\php-cgi.exe" maxInstances="10" instanceMaxRequests="10000"> <environmentVariables> <environmentVariable name="PHPRC" value="E:\ZendServer\etc" /> <environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" /> </environmentVariables> </application> </fastCgi> © All rights reserved. Zend Technologies, Inc. Debugging ● Debug-Prozess bricht nach 30 Sekunden ab ▶ ▶ Default-Werte für activityTimeout & requestTimeout Demo … <application fullPath="E:\Zend\ZendServer\bin\php-cgi.exe" maxInstances="10" instanceMaxRequests="10000" activityTimeout="300" requestTimeout="300"> © All rights reserved. Zend Technologies, Inc. SQL Server © All rights reserved. Zend Technologies, Inc. Microsoft SQL Server Native Client © All rights reserved. Zend Technologies, Inc. Microsoft SQL Server Native Client ● Microsoft SQL Server 2008 Native Client ● http://www.microsoft.com/downloads ● Suche nach „SQL Server Native Client“ © All rights reserved. Zend Technologies, Inc. SQL Server Extension © All rights reserved. Zend Technologies, Inc. Zugriff mit Zend Framework ● Zend_Db_Adapter_Sqlsrv ● Demo … $db = Zend_Db::factory( 'Sqlsrv', array( 'host' => 'dbhost', 'username' => 'jan', 'password' => '******', 'dbname' => 'AdventureWorks' ) ); © All rights reserved. Zend Technologies, Inc. SQL Server Driver for PHP 2.0 ● http://www.microsoft.com/downloads ● Suche nach „SQL Server Driver for PHP“ ● Neu: PDO! ● Demo… © All rights reserved. Zend Technologies, Inc. Dankeschön! [email protected] © All rights reserved. Zend Technologies, Inc.