Make Web, Not War - Dev Fest: Why PHP Apps Rock On Windows, Paul Laberge

12,287 views

Published on

Discover PHP On Windows, Microsoft's Web Platform Installer & How to build web solutions with style using Expression Web 3

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
12,287
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Make Web, Not War - Dev Fest: Why PHP Apps Rock On Windows, Paul Laberge

  1. 1. Wh y P H P A p p s Ro c k o n Wi n d o w s make web, not war. Paul Laberge Web Platform Advisor paul.laberge@microsoft.com http://blogs.msdn.com/seesharp
  2. 2. G o a l s f o r T o d a y ’s Se s s i o n • PHP on Windows • Why it used to suck • Why it doesn’t suck anymore • Tools to make PHP on Windows rock • The Web Platform Installer • Explain what it is • Show you what it does • Describe how you can use it • Expression Web 3 • How to build web solutions with style! • Discuss next steps
  3. 3. Po l l t h e Au d i e n c e When I am building PHP apps, I: A. Avoid Windows like the plague B. Use Linux because everyone knows it’s best for PHP apps! C. Wish I could run my PHP app on Windows D. Wish I thought of AwkwardFamilyPhotos.com before anyone else actually did
  4. 4. 3 Dev Challenges (pick one): • Build a PHP-based (or ASP.NET) Music Collection hosted on a Windows Machine • Create a WordPress or Drupal instance using the WPI and building a custom theme • Develop a PHP-based Twitter app hosted on Windows Build the App, Win a Prize CHAL L E NGE
  5. 5. A history of embarrassment P HP ON WI N D O WS , T H E UGL Y
  6. 6. I n t h e b e g i n n i n g ... • First real foray into the enterprise was Windows NT • Predominantly a Client/Server OS • Fundamental approach to server design used for future Windows Server versions Image Source: Wikipedia (http://en.wikipedia.org/wiki/File:Windows_NT_3.5_logo.png) F u n d a me n t a l P h i l o s o p h y f o r Wi n d o w s M a k e m u l t i -t h r e a d i n g e a s y . S p i n n i n g u p mu l t i p l e p r o c e s s e s i s n o t a s i mp o r t a n t .
  7. 7. Th r e a d v s Pr o c e s s – t h e r e i n l i e s Wi n d o w s ’ i s s u e wi t h PHP Each time a request to a PHP page is made, the PHP platform spins up a new process. U N I X -B a s e d Wi n d o w s S y s t e ms • Spinning up a process is a •S y s t e up s process is a heavy Spinning m a lightweight operation operation • To do this, Windows calls a • Creating a new thread is not a Hard Page Fault (most costly lightweight operation operation in the OS) • Creating a new thread is a very lightweight operation A s P H P r e q u e s t s a d d u p , Wi n d o w s g e t s b o g g e d d o wn u n d e r t h e we i g h t o f c r e a t i n g p r o c e s s e s .
  8. 8. Ea r l y s o l u t i o n s we r e n o t , u h , o p t i ma l • We built an ISAPI application to handle PHP requests which would make response time very Ru n c r a z y fast f a s t , c r a s • Sounds great at first, but... h c r a z y • ISAPI applications are threadsafe and require of t e n applications using them to be re-entrant • PHP isn’t really threadsafe and it isn’t re- entrant. • Use Common Gateway Interface (CGI), just like Ru n PHP intended s l o w, Cr a s • CGI spins up a process for each request h l e s s • Have a process creation performance problem? Too bad, so sad. As y o u c a n s e e , b o t h o f t h e s e o p t i o n s p r e s e n t t h e i r o wn c h a l l e n g e s !
  9. 9. Po l l t h e Au d i e n c e I have: A. Run Crazy Fast, Crash Crazy Often with PHP on Windows B. Run Slow, Crashed Less Often with PHP on Windows C. Avoided PHP on Windows to avoid crashing and slowness. D. Often wished ICanHasCheezburger didn’t exist.
  10. 10. We’ve made a comeback. And we brought friends. P HP ON WI N D O WS , T H E GOOD
  11. 11. E n t e r : F a s t CGI Ba c k g r o u • Microsoft realized there was a PHP on Windows n d : Wh a t problem. Finally. y ou ne e d • Microsoft entered a partnership with Zend to t o k now fix the problem. • Result: FastCGI for IIS • FastCGI is an add-on to IIS 6 and 7 that gives performance 20x better than other PHP on Re s u l t Windows solutions • Very reliable performance and stability • Free
  12. 12. F a s t CGI i n I I S 6 a n d I I S 7 • FastCGI: The best of both CGI and ISAPI – Enhancement to CGI protocol – Web server creates FastCGI process pool for very first request – Web server re-uses existing FastCGI processes for subsequent requests – Configurable Resources – Download for IIS 6 – Ships in IIS 7, installed with the CGI feature • Benefits of FastCGI for Windows – Much faster than CGI because there is no process creation cost – Much more stable than ISAPI because of single threaded execution environment N o n -t h r e a d s a f e P H P b u i l d s a r e r e c o mme n d e d f o r F a s t C G I
  13. 13. H o w F a s t C G I Wo r k s (w i t h c h e e s y g r a p h i c s ) IIS grabsFastCGI The an available The IIS IIS IISready for is sends process for theup Module spins PHP service is requests results of PHP request and uses it a number of started request to user. processes on Process is Windows. returned to pool. I  PHP o n . AUser gets the User requests a PHP page User PHP page. from thehappy. is Server
  14. 14. Un d e r t h e c o v e r s wi t h I I S 7, i t ’s a b o u t t h e mo d u l a r a r c h i t e c t u r e FastCGI process pool for PHP5 FastCGI protocol IIS Worker Process over named pipes or TCP php-cgi.exe FastCGI process pool for PHP4 Request php.exe queue
  15. 15. L e t ’s s e e w h a t d e we c a n c r a s h t o d a y mo My god, it’s full of <? phpinfo(); ?>! • Modular architecture. As opposed to monolithic. • Hosting multiple versions of PHP: I would do that if I were you, Dave.
  16. 16. Po l l t h e Au d i e n c e The movie reference on the previous slide is: A. Khaaaaaaaan!!! B. 2001: A Space Odyssey / 2010: Odyssey 2 C. Chariots of Fire D. One time at bandcamp...
  17. 17. Th e I n t e g r a t e d Pi p e l i n e a n d PHP • IIS 7’s Integrated Pipeline enables ASP.NET to serve as the standard .NET extensibility mechanism for IIS7 • Provides the same familiar ASP.NET APIs and features for building web applications • ASP.NET provides a rich application framework for rapid application extensions to existing PHP applications E x a mp l e : A d d i n g A c c e s s C o n t r o l t o a n existing PHP application… Using PHP Using ASP.NET Building a custom credential store and Rich membership service, built-in credential cookie-based authentication store providers, the forms authentication from the ground up. module, and a set of pre-made Login controls.
  18. 18. What? Microsoft made it easy to do something? That’s crazy talk! T H E WE B P L AT F ORM I NST AL L ER
  19. 19. I n t r o d u c i n g t h e We b Pl a t f o r m I n s t a l l e r The “plumbing” associated with Aspiration web solutions should not get in your way building great applications. It’s a mess. Reality
  20. 20. I n t r o d u c i n g t h e We b Pl a t f o r m I n s t a l l e r The Microsoft Web Platform Installer is our way of making that mess a little easier to deal with. It won’t take away all the pain of setting up an environment, but it takes away a lot of it. Today I’ll show you Version 1 and Version 2 Beta of the WPI and how you can use it to set up your web environments. And you don’t even need to use .NET if you don’t want...
  21. 21. Wh a t d o e s t h e WP I wo r k wi t h ? The Microsoft Web Platform is a powerful set of tools, servers, and technologies optimized for building and hosting next generation web applications and solutions. Microsoft Web Platform Installer: Simple discovery and install free web stack and Web App Gallery apps Tools Servers Technologies Can’t We All Just Work Together? Design and development integration for pre- packaged Open Source applications that run on top of the Microsoft Web Platform including:
  22. 22. d e L e t ’s s e e w h a t we c a n c r a s h t o d a y mo Almost one-stop shopping – http://microsoft.com/web
  23. 23. R e c a p o f t h e WP I I n s t a l l e r , Ve r s i o n 1 • Installing base platform software Good For • Custom developers building web solutions from scratch Not So • Installing third party apps like WordPress or DotNetNuke Good For
  24. 24. T h e We b A p p G a l l e r y The Web App Gallery is a component of the Microsoft Web Platform site that allows you to install community-based web solutions and to submit your own web solutions.
  25. 25. S u b mi t t i n g A p p s t o t h e We b A p p G a l l e r y Check out the Web App Gallery Principles document to ensure your application adheres to the requirements for submission. • (Link: http://learn.iis.net/page.aspx/605/windows-web-application-gallery-principles/) Package your app into the format required by the WPI in order for it to be configured via the installer application. • (Link: http://learn.iis.net/page.aspx/578/application-packaging-guide-for-the- windows-web-application-gallery/ ) Submit your app to the gallery via the process on the site. You’ll need a Windows Live ID in order to submit your app. • (Link: http://www.microsoft.com/web/gallery/Submit.aspx )
  26. 26. L e t ’s s e e w h a t d e we c a n c r a s h t o d a y mo The Web App Gallery – For both artists and consumers • Review of the Web App Gallery on http://microsoft.com/web • Creating and submitting applications to the Web App Gallery
  27. 27. Po l l t h e Au d i e n c e I plan on: A. Building an app for the WPI and submitting it to the gallery B. Not building an app for the WPI.
  28. 28. WP I : T N G * WPI, Version 2 (Beta) is the next step in providing an easy way to install the pieces of a web solution you need. • Platform installation support (i.e.: What WPI, Version 1 What’s had) “In the Box” • One-Stop Shopping of the Web App Gallery inside the WPI Installer *: The Next Generation. But you probably already knew that!
  29. 29. L e t ’s s e e w h a t d e we c a n c r a s h t o d a y mo WPI Version 2 (Beta) – When you need to “turn it up to 11” • Tour of WPI, Version 2 (Beta) • Let’s create a WordPress Instance. Oh, and a DotNetNuke instance, too. Just for the heck of it.
  30. 30. Ex c u s e u s f o r t h e h i c c u p s A few words of advice (from someone who has felt the pain): • Before using the WPI, if you need MySQL for any of your database needs, install it first! • The MySQL installer for Windows is a little wonky at times and may cause issues for you if you need to install apps that need MySQL My experience installing MySQL (confirmed with others’ experience as well): • The MySQL installer installs the database system without any noticeable errors • The issue is that the password you enter for the root user is ignored and left blank • Result is that you can’t install any app via the WPI as you need a root password to install the database
  31. 31. Th e s o l u t i o n I u s e d t o t h e My S Q L i s s u e Ok, so I didn’t figure this out on my own, but I found an answer that worked for me. To solve the root password reset issue: • Link: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html • Log in as an administrator • If the MySQL service is running, stop it S u mma r i z e • Create a text file on C: with the following text: So l u t i o n UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES; (where “MyNewPass” is the new password you want. Please note that the UPDATE and St e p s FLUSH commands must be on separate lines of the text file, just as you see in the example above.) • Save the text file as C:mysql-init.txt. • Open a command window as administrator and execute the following command: d C:%MySQL_BIN_PATH%mysqld --init-file=C:mysql-init.txt (where “%MySQL_BIN_PATH%” is the path to where your MySQL engine was installed. On my machine this was c:Program FilesMySQLMySQL 5.1bin.) • Delete the C:mysql-init.txt file you created. • Stop the MySQL service and restart it normally (i.e. Using the “Services” utility in Control Panel, not using the command line) • The root password should now be the one you designated in the C:mysql-init.txt file. • If the password is not recognized, try re-booting the box.
  32. 32. If you’re gonna build it, build it with style. E X P R E S S I O N WE B
  33. 33. I n t r o d u c i n g E x p r e s s i o n We b Expression Web is Microsoft’s “new” tool for building professional websites. Features: • Native support for PHP, ASP.NET, XML, etc. • Full CSS management capabilities • Ability to create standards-based websites
  34. 34. d e L e t ’s s e e w h a t we c a n c r a s h t o d a y Fr i e n d s d o n ’t l e t f r i e n d s • • • • Language Support CSS Support Standards Support mo Cross-Browser Support u s e Fr o n t Pa g e
  35. 35. E x p r e s s i o n We b Su p e r Pr e v i e w f o r I E Be t a • Part of Expression Web 3 • IE6 Rendering in Stand-alone tool (free) • Visual debugging tools • Side-by-side view • Overlay view • Grids & guides • Pan & zoom • DOM highlighting shows absolute positioning of rendered elements • HTML elements display CSS properties Download the beta here: http://www.microsoft.com/expression/try-it/superpreview
  36. 36. Po l l t h e Au d i e n c e SuperPreview: A. Is something I wish I had long ago. B. Is worth the price of Expression Web 3! C. Rocks! D. Meh.
  37. 37. O k , s o w h a t ’s n e x t ? • First and foremost, try the WPI (either Version 1 or Version 2). • Don’t believe me, try PHP on Windows for yourself and see how it runs! • Try out the trial of Expression Web for your PHP development • Download the Expression Web SuperPreview for IE Beta • If you install an application and use it outside of testing the WPI out, let me know. If you build an app for the WPI, let me know. We have opportunities to help you market it! • Check out the resource links at the end of this presentation (if you’re watching this via the webcast, you can download the slide deck from Live Meeting which I’ll now explain how to do. • Check out the offers on the next few slides. They may interest you.
  38. 38. O k , s o w h a t ’s n e x t ? • First and foremost, try the WPI (either Version 1 or Version 2). • If you install an application and use it outside of testing the WPI out, let me know. If you build an app for the WPI, let me know. We have opportunities to help you market it! • Check out the resource links at the end of this presentation
  39. 39. Yo u a r e c o r d i a l l y i n v i t e d Registration Link: http://www.microsoft.com/canada/emailcampaigns/ptr/mwnw2pt/eng/default.aspx
  40. 40. Where to get the info RE S OURCE S
  41. 41. L i n k s a n d Re s o u r c e s • Main Websites • Microsoft Web Platform Portal: http://www.microsoft.com/web • Canadian PHP on Windows Portal: http://phponwindows.ca • Everything PHP on IIS: http://www.iis.net/php • Microsoft Canada Web Solutions Portal: http://www.microsoft.com/canada/websolutions/ • CodePlex – Microsoft’s Open Source Portal: http://www.codeplex.com • Port25 – Microsoft’s Open Source Community Site: http://port25.technet.com/ • Main ASP.NET Portal: http://www.asp.net • Blogs • Canadian Developer Blog: http://blogs.msdn.com/cdndevs • Canadian IT Pro Blog: http://blogs.technet.com/canitpro • Joey deVilla’s Blog: http://www.globalnerdy.com/ • Tutorials and Tips • MySQL Root Password Change Issue: http://dev.mysql.com/doc/refman/5.0/en/resetting- permissions.html • IIS 7 Learning Centre: http://learn.iis.net/ • Offers and Contests • FTW! The Ultimate App Throwdown Contest: http://www.phponwindows.ca/FTW/index.php • Join the Microsoft Canada Partner Program: http://www.microsoft.com/canada/websolutions/partner- program.aspx • myhosting Windows Hosting Offer: http://myhosting.com/Promotions/2009MS/ • RackForce Windows Hosting Offer: http://www.rackforce.com/windows_servers/mspro.html • Recommended Twitter Follows • Microsoft Canada for PHP on Windows (@PHPonWindows): http://www.twitter.com/PHPonWindows • Joey deVilla (@AccordianGuy): http://www.twitter.com/AccordianGuy • Nik Garkusha (@Nik_G): http://www.twitter.com/Nik_G • Paul Laberge (@plaberge): http://www.twitter.com/plaberge • The Microsoft Web Platform (@mswebplatform): http://www.twitter.com/mswebplatform • Angie Lim (@angielim): http://www.twitter.com/angielim • Microsoft Partner Program (@msPartner): http://www.twitter.com/msPartner
  42. 42. L i n k s a n d Re s o u r c e s , Co n t i n u e d • Main Websites • Main Expression Studio Portal: http://expression.microsoft.com • Expression Web Portal: http://expression.microsoft.com/en-ca/cc136529.aspx • SuperPreview Beta Download: http://www.microsoft.com/expression/try-it/superpreview • Microsoft’s Canadian Web Solutions Portal: http://www.microsoft.ca/websolutions • Blogs • Canadian UX Blog: http://blogs.msdn.com/canux • Anna Ullrich’s Blog: http://blogs.msdn.com/anna/ • Morten Rand-Hendriksen’s Blog: http://www.designisphilosophy.com • Expression Web Product Blog: http://blogs.msdn.com/xweb/ • Tutorials and Tips • Free Expression Web Training Videos: http://expression.microsoft.com/en-ca/cc197140.aspx • LearnExpression: http://www.learnexpression.com/ • Recommended Twitter Follows • Morten Rand-Hendriksen: @mor10 • Anna Ullrich: @annaullrich • Official Expression Product Account: @MSExpression • Tina Clarke’s Account: @expressionweb
  43. 43. Visual Studio Attach an Professional VSTS Edition MSDN Purchase an Users Users Subscription Expression Step Up to Step Up to to your Professional VSTS Dev Team Suite VS Pro Subscription Edition For 30% off! License and and save For 30% off! Save! 25%!
  44. 44. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

×