• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Codeworks'12 Rock Solid Deployment of PHP Apps
 

Codeworks'12 Rock Solid Deployment of PHP Apps

on

  • 4,303 views

Web applications are becoming increasingly more complex, so deployment is not just transferring files with FTP anymore. We will go over the different challenges and how to deploy our PHP applications ...

Web applications are becoming increasingly more complex, so deployment is not just transferring files with FTP anymore. We will go over the different challenges and how to deploy our PHP applications effectively, safely and consistently with the latest tools and techniques.

Statistics

Views

Total Views
4,303
Views on SlideShare
3,954
Embed Views
349

Actions

Likes
6
Downloads
20
Comments
1

3 Embeds 349

http://www.scoop.it 324
https://twitter.com 24
http://tweetedtimes.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Codeworks'12 Rock Solid Deployment of PHP Apps Codeworks'12 Rock Solid Deployment of PHP Apps Presentation Transcript

    • Rock Solid Deployment of PHP Applications Pablo Godel @pgodel - codeworks.phparch.com Oct 3rd 2012 - Boca Raton, FLWednesday, October 3, 2012
    • Who Am I? ⁃ Born in Argentina, living in the US since 1999 ⁃ PHP & Symfony developer ⁃ Founder of the original PHP mailing list in spanish ⁃ Master of the parrillaWednesday, October 3, 2012
    • Wednesday, October 3, 2012
    • Wednesday, October 3, 2012
    • ServerGrove! ⁃ Founded ServerGrove Networks in 2005 ⁃ Provider of web hosting specialized in PHP, Symfony, ZendFramework, MongoDB and others ⁃ Servers in USA (right here in Miami) and Europe!Wednesday, October 3, 2012
    • Community is our teacher ⁃ Very active open source supporter through code contributions and usergroups/conference sponsoringWednesday, October 3, 2012
    • Deployment ?Wednesday, October 3, 2012
    • Deployment Software deployment is all of the activities that make a software system available for use. http://en.wikipedia.org/wiki/Software_deploymentWednesday, October 3, 2012
    • Deployment A very important part of the application life-cycleWednesday, October 3, 2012
    • Deployment A very important critical part of the application life-cycleWednesday, October 3, 2012
    • Deployment It should not be an after thoughtWednesday, October 3, 2012
    • Deployment It should be predictableWednesday, October 3, 2012
    • Deployment The more you do it the better it goesWednesday, October 3, 2012
    • Wednesday, October 3, 2012
    • Deployment: GoalsWednesday, October 3, 2012
    • Deployment: Goals One-click deploysWednesday, October 3, 2012
    • Deployment: Goals Continuous deploysWednesday, October 3, 2012
    • PHP Apps DeploymentWednesday, October 3, 2012
    • PHP Apps DeploymentWednesday, October 3, 2012
    • PHP Apps DeploymentWednesday, October 3, 2012
    • Deployment: Goals Anytime & AnywhereWednesday, October 3, 2012
    • Deployment: Goals AnyoneWednesday, October 3, 2012
    • Deployment: Goals ReliableWednesday, October 3, 2012
    • Deployment: Goals RollbacksWednesday, October 3, 2012
    • Deployment: Goals No downtimeWednesday, October 3, 2012
    • Deployment: Goals ReusableWednesday, October 3, 2012
    • Deployment: Goals ScalableWednesday, October 3, 2012
    • Deployment: Goals • One-click / continuous deploys • Anytime & Anywhere • Anyone • No downtime • Predictable & Reliable • Rollbacks • Reusable • ScalableWednesday, October 3, 2012
    • Deployment FactsWednesday, October 3, 2012
    • Deployment: Fact #1 Deployment starts with the developer • Setup development environment to be as close as possible to productions servers • Setup test/qa/staging servers • Use Vagrant to manage VMs • Use Puppet/Chef to manage OS packages/ configurationWednesday, October 3, 2012
    • Deployment: Fact #2 Success linked to server OS setup • Use Puppet/Chef to manage OS packages/ configuration • Create OS packages for 3rd party software • Setup your own package repositoriesWednesday, October 3, 2012
    • Deployment: Fact #3 Monitoring is uptime • Use monitoring tools to know what is going on with your servers (Ganglia, Cacti, Zabbix, etc.) • Add monitoring and metrics to your app (Graphite, StatsD, New Relic) • Use your logs wisely (Graylog, Logstash, Kibana)Wednesday, October 3, 2012
    • Deployment MethodologiesWednesday, October 3, 2012
    • Deployment Methodologies • VIM-style • FTP uploads • rsync • source control (svn, git) • Build tools (ant, phing) • Specialized tools (capistrano, fabric, etc) • Package based (rpm, deb, etc)Wednesday, October 3, 2012
    • Web Apps Deployment: Steps overviewWednesday, October 3, 2012
    • Web Apps Deployment: First time • Copy files to server(s) • Set server-side configurations • Load DB fixtures • Process and install assets • Warm up cache • “Enable” siteWednesday, October 3, 2012
    • Web Apps Deployment: Subsequent times • Copy files to server(s) • Apply DB updates (migrations) • Process and install assets • Warm up cache • “Enable” siteWednesday, October 3, 2012
    • Deployment: ChallengesWednesday, October 3, 2012
    • Deployment: Challenges Challenge: Fast & reliable copy of files Solutions: • rsync • git pull • setup git repo on local network to save bandwidth and avoid issues if git server is down (i.e. github)Wednesday, October 3, 2012
    • Deployment: Challenges Challenge: Scalable Solutions: • use a tool that allows to go from 1 to n servers easily (i.e. capistrano) • pssh allows to send commands to n servers in parallel • package your app in OS packages like .rpm/.deb to easily install across n serversWednesday, October 3, 2012
    • Deployment: Challenges Challenge: Rollbacks Solutions: • test! • tag releases • dedicated branches (master for production) • deploy each release in its own directoryWednesday, October 3, 2012
    • Deployment: Challenges Challenge: Secure Solutions: • use ssh based connections • donʼt store passwords on source control • store sensitive strings (passwords) in server environment variablesWednesday, October 3, 2012
    • Deployment: Challenges Challenge: DB migrations Solutions: • Doctrine Migrations • Consider document oriented DBs like MongoDB “The best migrations are the ones you don’t have to do”Wednesday, October 3, 2012
    • Deployment: Challenges Challenge: Static assets Solutions: • YUICompress shrinks JS and CSS file sizes • Enable web server compression • Add versioning to static assets links (code.js?v=1) • Assetic combines multiple files into one • Run utilities locally or in a staging server, deploy resultWednesday, October 3, 2012
    • Deployment: Challenges Challenge: Caching Solutions: • Update one server while others handle load • Group servers and update group at a time • execute commands on “finalize” to clear up APC cacheWednesday, October 3, 2012
    • Deployment: Challenges Challenge: File permission conflicts Solutions: • Run Apache/PHP with same user • Use php-fpm instead of mod_php • Create “deploy” user and add web server to the group • Use setfacl to give write access to multiple usersWednesday, October 3, 2012
    • PHP Apps Deployment: Other common pitfallsWednesday, October 3, 2012
    • PHP Apps Deployment: Other common pitfalls • Case sensitive filesystems • Configuration differences • Outdated 3rd party software • Github down $ git daemon --base-path=/git/repo/path/ -- export-all $ git clone git://127.0.0.1/repo http://ozmm.org/posts/when_github_goes_down.htmlWednesday, October 3, 2012
    • PHP Apps Deployment: ExamplesWednesday, October 3, 2012
    • PHP Apps Deployment: Examples Simplest continuous deployment ever! hook.php <?php exec(ʻ/usr/bin/env -i HOME=/var/www git pullʼ); echo “All done!”; screenshotWednesday, October 3, 2012
    • PHP Apps Deployment: Examples Capistrano • Ruby based • Very extensible • Large number of extensions • Simple client side installation $ gem install capistranoWednesday, October 3, 2012
    • PHP Apps Deployment: Examples Capistrano set :application, "myapp" # Application name set :deploy_to, "/var/www/myapp" set :user, "deployer" set :use_sudo, false # sudo isnt required set :deploy_via, :remote_cache set :repository, "git@github.com:user/repo.git" role :web, "server.example.com", “server2.example.com”Wednesday, October 3, 2012
    • PHP Apps Deployment: Examples Capistrano $ cap deploy $ cap deploy:migrations $ cap deploy:rollbackWednesday, October 3, 2012
    • PHP Apps Deployment: Examples Capifony (Symfony2) • Extension of Capistrano • Implements lots of needed features for Symfony • Great documentationWednesday, October 3, 2012
    • PHP Apps Deployment: Examples Capifony (Symfony2) $ capifony .Wednesday, October 3, 2012
    • PHP Apps Deployment: Examples Capifony (Symfony2) set :keep_releases, 3 # directories that will be shared between all deployments set :shared_children, [ app_path + "/logs", web_path + "/ uploads"] set :update_vendors, true # set :use_composer, true set :dump_assetic_assets, trueWednesday, October 3, 2012
    • PHP Apps Deployment: Examples Capifony (Symfony2) $ cap deploy:setupWednesday, October 3, 2012
    • PHP Apps Deployment: Examples Capifony (Symfony2) |-- httpdocs | `-- index.php |-- releases `-- shared |-- logs `-- uploads 5 directories, 1 fileWednesday, October 3, 2012
    • PHP Apps Deployment: Examples Capifony (Symfony2) $ cap deploy $ cap deploy:migrations $ cap deploy:rollbackWednesday, October 3, 2012
    • PHP Apps Deployment: Other options • Fabric • WePloy • Phing • Magallanes • JenkinsWednesday, October 3, 2012
    • PHP Apps Deployment: ToolsWednesday, October 3, 2012
    • PHP Apps Deployment: Tools App Metrics: StatsD & GraphiteWednesday, October 3, 2012
    • PHP Apps Deployment: Tools Logging: Logstash Ship logs from any source, parse them, get the right timestamp, index them, and search themWednesday, October 3, 2012
    • PHP Apps Deployment: Tools Logging: Logstash Configure Apache to log json LogFormat "{ "@timestamp": "%{%Y-%m-%dT%H:%M:%S%z}t", "@fields": { "client": "%a", "duration_usec": %D, "status": %s, "request": "%U%q", "method": "%m", "referrer": "% {Referer}i" } }" logstash_json # Write our logstash_json logs to logs/access_json.log CustomLog logs/access_json.log logstash_json Result { "@timestamp": "2012-08-22T14:35:19-0700", "client": "127.0.0.1", "duration_usec": 532, "status": 404, "request": "/favicon.ico", "method": "GET", "referrer": "-" }Wednesday, October 3, 2012
    • PHP Apps Deployment: Tools Logging: GraylogWednesday, October 3, 2012
    • PHP Apps Deployment: Tools Logging: Kibana Kibana is a user friendly way to view, search and visualize your log dataWednesday, October 3, 2012
    • PHP Apps Deployment: Tools Packaging: fpm Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity. fpm -s dir -t rpm -n "myapp" -v 1.0 /var/www/myapp fpm -s dir -t deb -a all -n myapp -v 1.0 /etc/apache2/ conf.d/my.conf /var/www/myapp https://github.com/jordansissel/fpmWednesday, October 3, 2012
    • PHP Apps Deployment: Time for demoWednesday, October 3, 2012
    • PHP Apps Deployment: SummaryWednesday, October 3, 2012
    • •Stop using FTPWednesday, October 3, 2012
    • •Stop using FTP •Plan earlyWednesday, October 3, 2012
    • •Stop using FTP •Plan early •PracticeWednesday, October 3, 2012
    • •Stop using FTP •Plan early •Practice •MonitorWednesday, October 3, 2012
    • •Stop using FTP •Plan early •Practice •Monitor •AUTOMATE!Wednesday, October 3, 2012
    • QUESTIONS? Feedback: http://joind.in/event/view/1062 Slides: http://slideshare.net/pgodel Twitter: @pgodel E-mail: pablo@servergrove.comWednesday, October 3, 2012
    • Thank you! Feedback: https://joind.in/7227 Slides: http://slideshare.net/pgodel Twitter: @pgodel E-mail: pablo@servergrove.comWednesday, October 3, 2012