make web, not war - dev fest: why php apps rock on windows, paul laberge
DESCRIPTION
Discover PHP On Windows, Microsoft's Web Platform Installer & How to build web solutions with style using Expression Web 3TRANSCRIPT
make web, not war.
Why PHP Apps Rock on Windows
Paul LabergeWeb Platform [email protected]://blogs.msdn.com/seesharp
Goals for Today’s Session
• 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
Poll the Audience
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
CHALLENGEBuild the App, Win a Prize
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
PHP ON WINDOWS, THE UGLY
A history of embarrassment
In the beginning...
Image Source: Wikipedia (http://en.wikipedia.org/wiki/File:Windows_NT_3.5_logo.png)
• 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
Fundamental Philosophy for Windows
Make multi-threading easy. Spinning up multiple processes is not as important.
Thread vs Process – therein lies Windows’ issue with PHP
Each time a request to a PHP page is made, the PHP platform spins up a new process.
UNIX-Based Systems Windows Systems• Spinning up a process is a
lightweight operation
• Creating a new thread is not a lightweight operation
• Spinning up a process is a heavy operation• To do this, Windows calls a
Hard Page Fault (most costly operation in the OS)
• Creating a new thread is a very lightweight operation
As PHP requests add up, Windows gets bogged down under the weight of creating processes.
Early solutions were not, uh, optimal
Run crazy fast, crash crazy
often
Run slow, Crash less
• We built an ISAPI application to handle PHP requests which would make response time very fast
• Sounds great at first, but...• ISAPI applications are threadsafe and require
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 PHP intended
• CGI spins up a process for each request• Have a process creation performance problem?
Too bad, so sad.
As you can see, both of these options present their own challenges!
Poll the Audience
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.
PHP ON WINDOWS, THE GOOD
We’ve made a comeback. And we brought friends.
Enter: FastCGI
Background: What you need
to know
• Microsoft realized there was a PHP on Windows problem. Finally.
• Microsoft entered a partnership with Zend to fix the problem.• Result: FastCGI for IIS
Result
• FastCGI is an add-on to IIS 6 and 7 that gives performance 20x better than other PHP on Windows solutions
• Very reliable performance and stability• Free
FastCGI in IIS 6 and IIS 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
Non-thread safe PHP builds are recommended for FastCGI
How FastCGI Works (with cheesy graphics)
The IIS service is started
on Windows.
The FastCGI Module spins up
a number of processes
A User requests a PHP page from
the Server
IIS is ready for requests
IIS grabs an available process for the PHP request and uses it
User gets the PHP page. User
is happy.
IIS sends results of PHP request
to user. Process is returned to
pool.
I PHP on .
Under the covers with IIS 7, it’s about the modular architecture
IIS Worker Process
Read Configuration
Authenticate
Authorize
Map Request
Handle Request
Send Response
Log Request
FastCGI handler
ASP.NET
Static
Request queue
FastCGI process pool for PHP5
php-cgi.exe
FastCGI process pool for PHP4
php.exe
FastCGI protocol over named pipes or TCP
demo
• Modular architecture. As opposed to monolithic.• Hosting multiple versions of PHP: I would do that if I were you, Dave.
Let’s see what we can crash today
My god, it’s full of <? phpinfo(); ?>!
Poll the AudienceThe 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...
The Integrated Pipeline and 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
Example: Adding Access Control to an existing PHP application…
Using PHP Using ASP.NET
Building a custom credential store and cookie-based authenticationfrom the ground up.
Rich membership service, built-in credential store providers, the forms authentication module, and a set of pre-made Login controls.
THE WEB PLATFORM INSTALLER
What? Microsoft made it easy to do something? That’s crazy talk!
Introducing the Web Platform Installer
Aspiration
Reality
The “plumbing” associated with web solutions should not get in your way building great applications.
It’s a mess.
Introducing the Web Platform Installer
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...
What does the WPI work with?
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:
demoAlmost one-stop shopping – http://microsoft.com/web
Let’s see what we can crash today
Recap of the WPI Installer, Version 1
Good For
Not So Good For
• Installing base platform software
• Custom developers building web solutions from scratch
• Installing third party apps like WordPress or DotNetNuke
The Web App Gallery
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.
Submitting Apps to the Web App Gallery
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 )
demoThe 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
Let’s see what we can crash today
Poll the Audience
I plan on:
A. Building an app for the WPI and submitting it to the gallery
B. Not building an app for the WPI.
WPI: TNG*
*: The Next Generation. But you probably already knew that!
WPI, Version 2 (Beta) is the next step in providing an easy way to install the pieces of a web solution you need.
What’s “In the Box”
• Platform installation support (i.e.: What WPI, Version 1 had)
• One-Stop Shopping of the Web App Gallery inside the WPI Installer
demoWPI 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.
Let’s see what we can crash today
Excuse us for the hiccups
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
The solution I used to the MySQL issue
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
Solu
tion S
tep
s Su
mm
ari
zed
• Log in as an administrator• If the MySQL service is running, stop it• Create a text file on C:\ with the following text:
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 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:
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 Files\MySQL\MySQL 5.1\bin\.)
• 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.
EXPRESSION WEBIf you’re gonna build it, build it with style.
Introducing Expression Web
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
demo• Language Support
• CSS Support• Standards Support• Cross-Browser Support
Friends don’t let friends
use FrontPage
Let’s see what we can crash today
Expression Web SuperPreview for IE Beta
• 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
Poll the Audience
SuperPreview:
A. Is something I wish I had long ago.
B. Is worth the price of Expression Web 3!
C. Rocks!
D. Meh.
Ok, so what’s next?
• 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.
Ok, so what’s next?
• 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
You are cordially invited
Registration Link: http://www.microsoft.com/canada/emailcampaigns/ptr/mwnw2pt/eng/default.aspx
RESOURCESWhere to get the info
Links and Resources
• 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
Links and Resources, Continued
• 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
Visual Studio Professional
UsersStep Up to VSTS Dev
EditionFor 30% off!
VSTS Edition Users
Step Up to Team SuiteFor 30% off!
Attach an MSDN
Subscription to yourVS Pro
License and Save!
Purchase an Expression
Professional Subscription
and save 25%!
© 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.