Write PHP, deploy  everywhere  Confoo 2011, Montreal (CA)
Michelangelo van Dam• Independent Consultant• Zend Certified Engineer (ZCE)• President of PHPBenelux
Topics    Live hacking     FTP deploy   Version controlAutomated deploymentAnywhere deployment
Related
Rob Allen  Stress Free Deployment                                http://www.flickr.com/photos/stuartherbert/5089882125http:...
Deployment types
Live Hacking
Good old days
FTP deploy
Manual FTP deploy
Version control
Code management
Versioning concepts
Symlink switch oldpath/to/webapppath/to/webapp-1.0.2 -> path/to/webapppath/to/webapp-1.0.3
Symlink switch newpath/to/webapppath/to/webapp-1.0.2path/to/webapp-1.0.3 -> path/to/webapp
Automated deployment
Concept: build• required steps•- to “build” an application     validate -   test -   document -   package
All tools needed!
Phing• build tool written in PHP• comparable to ANT build scripts• impressive list of task templates• extensible for missi...
Phing HelloWorld!<?xml version="1.0" encoding="UTF-8"?><project name="demo" default="build">  <target name="build">    <ec...
Export from SVN<property name="buildpath" value="./build"/><property name="repopath"          value="https://svn.myserver....
More info: phing.info
Anywhere deployment
Deployment options• platform (windows, linux, i5, …)• database engine (mysql, ms sql, oracle)•- deployment protocols     r...
Linux server
Example deploy Linux<target name="deploy-linux">    <exec dir="./build"          command="rsync -rq user@server.com:/srv/w...
Windows server
Deploy to windows<target name="deploy-windows" depends="version-bugfix">    <ftpdeploy host="${env.win-prod}"             ...
Windows Azure
A few remarks•- runs only on windows    but still uses phing :-)• takes a considerable time to upload• instances are define...
Setting properties<property  name="cmd-cspack"  value="c:Program FilesWindows Azure SDKv1.3bincspack.exe"  override="false...
Prepare for Azure<target name="prepare-azure" depends="version-bugfix">    <!-- start building in ./bldtmp -->    <mkdir d...
Deploy to Azure<target name="deploy-azure" depends="prepare-azure">    <exec command="&quot;${cmd-cspack}&quot;ServiceDefi...
Continuous Integration
Continuous Building
Considerations
Some reminders•- design your apps to work everywhere    use OOP abstraction layers - use plugins - take care of sessions!•...
automate what you might   forget under stress!
Questions• http://slideshare.net/DragonBe/write-php-deply-  everywhere• http://twitter.com/DragonBe• http://facebook.com/D...
Write php deploy everywhere
Write php deploy everywhere
Write php deploy everywhere
Write php deploy everywhere
Write php deploy everywhere
Write php deploy everywhere
Upcoming SlideShare
Loading in...5
×

Write php deploy everywhere

7,929

Published on

As a PHP developer building web applications is besides making a living a lot of fun too, especially when you can deploy your apps to any kind of environment and on any platform. In this session I take a non-standard PHP application (based on Zend Framework) and deploy it to a bare metal environment running LAMP, Windows 2008 Server with IIS7 and to cloud instances like Azure and Amazon.
The goal is to provide information on how to deploy to these various environments manual and automatic, but also to show it doesn't really matter anymore what the targeted platform is, as long the apps are written in PHP.

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

No Downloads
Views
Total Views
7,929
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
31
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • manual modifying on server\nno return to previous\nfailures visible\n\n
  • \n
  • local files &amp;#x201C;out-of-sync&amp;#x201D;\noverwriting code of others\nno previous version\n
  • \n
  • all go to a central (or decentral) repository\ncode is versioned\nwhen failure, you can revert\n
  • snapshot tag -&gt; deployment package\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • WA SDK: http://msdn.microsoft.com/en-us/windowsazure\n
  • \n
  • first create a package with 2 instances\nthan deploy to azure\n
  • \n
  • WA Manager\n- two instances\n
  • \n
  • perfect world\n
  • \n
  • layers: db, services\nplugins: caching solutions -&gt; OS detection\n
  • when your boss asks you to deploy quickly\n- you might forget steps\ncomputers are good at doing repeated tasks\n- use that!\n
  • if you&amp;#x2019;re interested in cloud deployment\n- phpa - Feb 2011 issue\n
  • \n
  • Write php deploy everywhere

    1. 1. Write PHP, deploy everywhere Confoo 2011, Montreal (CA)
    2. 2. Michelangelo van Dam• Independent Consultant• Zend Certified Engineer (ZCE)• President of PHPBenelux
    3. 3. Topics Live hacking FTP deploy Version controlAutomated deploymentAnywhere deployment
    4. 4. Related
    5. 5. Rob Allen Stress Free Deployment http://www.flickr.com/photos/stuartherbert/5089882125http://akrabat.com/talks/#sfd
    6. 6. Deployment types
    7. 7. Live Hacking
    8. 8. Good old days
    9. 9. FTP deploy
    10. 10. Manual FTP deploy
    11. 11. Version control
    12. 12. Code management
    13. 13. Versioning concepts
    14. 14. Symlink switch oldpath/to/webapppath/to/webapp-1.0.2 -> path/to/webapppath/to/webapp-1.0.3
    15. 15. Symlink switch newpath/to/webapppath/to/webapp-1.0.2path/to/webapp-1.0.3 -> path/to/webapp
    16. 16. Automated deployment
    17. 17. Concept: build• required steps•- to “build” an application validate - test - document - package
    18. 18. All tools needed!
    19. 19. Phing• build tool written in PHP• comparable to ANT build scripts• impressive list of task templates• extensible for missing tasks
    20. 20. Phing HelloWorld!<?xml version="1.0" encoding="UTF-8"?><project name="demo" default="build"> <target name="build"> <echo msg="Hello World!"/> </target></project>
    21. 21. Export from SVN<property name="buildpath" value="./build"/><property name="repopath" value="https://svn.myserver.com/demo/trunk"/> <target name="prepare"> <delete dir="${buildpath}" includeemptydirs="true" quiet="true" verbose="false" failonerror="false" /> <mkdir dir="${buildpath}"/> </target> <target name="getsources" depends="prepare"> <svnexport svnpath="/usr/bin/svn" force="true" nocache="true" repositoryurl="${repopath}" todir="${buildpath}"/> </target>
    22. 22. More info: phing.info
    23. 23. Anywhere deployment
    24. 24. Deployment options• platform (windows, linux, i5, …)• database engine (mysql, ms sql, oracle)•- deployment protocols rsync - FTP
    25. 25. Linux server
    26. 26. Example deploy Linux<target name="deploy-linux"> <exec dir="./build" command="rsync -rq user@server.com:/srv/www/demo"/></target>
    27. 27. Windows server
    28. 28. Deploy to windows<target name="deploy-windows" depends="version-bugfix"> <ftpdeploy host="${env.win-prod}" port="21" username="${auth.win-prod.username}" password="${auth.win-prod.password}" dir="/" mode="binary" clearfirst="false"> <fileset dir="."> <exclude=”./library/Zend”/> <exclude=”./library/ZendX”/> </fileset> </ftpdeploy></target>
    29. 29. Windows Azure
    30. 30. A few remarks•- runs only on windows but still uses phing :-)• takes a considerable time to upload• instances are defined in the config
    31. 31. Setting properties<property name="cmd-cspack" value="c:Program FilesWindows Azure SDKv1.3bincspack.exe" override="false"/><property name="cmd-csrun" value="c:Program FilesWindows Azure SDKv1.3bincsrun.exe" override="false"/>
    32. 32. Prepare for Azure<target name="prepare-azure" depends="version-bugfix"> <!-- start building in ./bldtmp --> <mkdir dir="./bldtmp" /> <copy todir="./bldtmp" overwrite="true"> <fileset dir="./deploy/azure"> <include name="**/*.*" /> </fileset> </copy> <copy todir="./bldtmp/PhpOnAzure.Web" overwrite="true"> <fileset dir="."> <include name="**/*"/> <include name="*"/> </fileset> </copy></target>
    33. 33. Deploy to Azure<target name="deploy-azure" depends="prepare-azure"> <exec command="&quot;${cmd-cspack}&quot;ServiceDefinition.csdef /role:PhpOnAzure.Web;PhpOnAzure.Web /out:PhpAzure.cspkg" dir="./bldtmp" /> <mkdir dir="./release/${phing.project.name}-${version.number}/azure-prod" /> <copy todir="./release/${phing.project.name}-${version.number}/azure-prod" overwrite="true"> <fileset dir="./bldtmp"> <include name="PhpOnAzure.cspkg"/> <include name="ServiceConfiguration.cscfg"/> </fileset> </copy></target>
    34. 34. Continuous Integration
    35. 35. Continuous Building
    36. 36. Considerations
    37. 37. Some reminders•- design your apps to work everywhere use OOP abstraction layers - use plugins - take care of sessions!• investigate “the other platform” - gives you a head start over competetion - teaches you the caveats• “cloud” solutions are in high-demand - see what works best for your customer
    38. 38. automate what you might forget under stress!
    39. 39. Questions• http://slideshare.net/DragonBe/write-php-deply- everywhere• http://twitter.com/DragonBe• http://facebook.com/DragonBe• http://joind.in/2782
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×