Successfully reported this slideshow.
Your SlideShare is downloading. ×

Write php deploy everywhere tek11

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Write php deploy everywhere
Write php deploy everywhere
Loading in …3
×

Check these out next

1 of 53 Ad

More Related Content

Slideshows for you (20)

Advertisement

Similar to Write php deploy everywhere tek11 (20)

More from Michelangelo van Dam (20)

Advertisement

Write php deploy everywhere tek11

  1. 1. Write PHP, deploy anywhere Tek 11 - Chicago, IL (USA)
  2. 2. m a I’ p e r v e lo D e
  3. 3. I write code
  4. 4. Not a sysadmin http://www.flickr.com/photos/scobleizer/4870003098/
  5. 5. Just want to run code
  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 old path/to/webapp path/to/webapp-1.0.2 -> path/to/webapp path/to/webapp-1.0.3
  15. 15. Symlink switch new path/to/webapp path/to/webapp-1.0.2 path/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. PHP provides the tools!
  19. 19. Phing •- build tool written in PHP comparable to ANT - but written in PHP :-) • 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. Deployment targets • scp • rsync • ftp •- VCM deployments cvs - svn - git - …
  23. 23. More info: phing.info
  24. 24. Anywhere deployment
  25. 25. Where to deploy to? • bare metal servers •- virtual servers even cloud instances • any OS (Windows, OSX, Linux, i5, …)
  26. 26. Linux server
  27. 27. Example deploy Linux <target name="deploy-linux"> <exec dir="./build" command="rsync -ruq user@server.com:/srv/www/demo"/> </target>
  28. 28. Windows server
  29. 29. 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>
  30. 30. Deploy to S3 <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>
  31. 31. Windows Azure
  32. 32. A few remarks •- runs only on windows but still uses phing :-) • takes a considerable time to upload • instances are defined in the config
  33. 33. Setting properties <property name="cmd-cspack" value="c:Program FilesWindows Azure SDKv1.3bin cspack.exe" override="false"/> <property name="cmd-csrun" value="c:Program FilesWindows Azure SDKv1.3bin csrun.exe" override="false"/>
  34. 34. 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>
  35. 35. 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>
  36. 36. Continuous Integration
  37. 37. Continuous Building
  38. 38. With CI • always “ready to deploy” codebase • feedback on quality • documentation • more …
  39. 39. Considerations
  40. 40. 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
  41. 41. automate what you might forget under stress!
  42. 42. Conclusion
  43. 43. 1. deployment is simple 2. automate the steps 3. deploy to any platform
  44. 44. Thank you • source code: http://github.com/DragonBe/zftest • your rating: http://joind.in/3438 •- follow me: twitter: @DragonBe - facebook: DragonBe Please use joind.in for feedback

×