SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Downloaden Sie, um offline zu lesen
twitter: @akrabat




Stress-free
Deployment
     Rob Allen




 ConFoo March 2011
Rob Allen?
•   PHP developer since 1999
•   Wrote Zend_Config
•   Tutorial at akrabat.com
•   Zend Framework in Action!

Next book!
 Zend Framework 2 in Action
 (with Ryan Mauger)
Why automate
deployment?
Getting your house in
        order
Source code control
Branch!
• Branch every new feature
 •   (that includes bug fixes)


• Be ready go live at all times
 •   Trunk deployment
 •   Live branch deployment
Trunk deployment
Live branch deployment
This is what I do
Database
considerations
One master database
• Live database holds master structure
• Copy master to everywhere else
• Advantages:
 • Simple to implement
• Disadvantages:
 •   Backwards compatibility required
 •   Doesnʼt scale for multiple devs well
 •   Easy to make mistakes
Migrations
• Versioned schemas
• Use delta files with UP and DOWN functions
• Advantages:
 •   version controlled
 •   destructive changes possible (but donʼt do it!)
• Disadvantages:
 •   Canʼt think of any!
Migrations tools
• DbDeploy
• LiquiBase
• Framework specific
 •   Doctrine
 •   Akrabat_Db_Schema_Manager
 •   Cake migrations
 •   PEAR: MDB2_Schema
• Home-brew script
For more info
“Database version control without the pain”
by Harrie Verveer

http://slidesha.re/gwq0aw

Also read http://www.harrieverveer.com/?p=247
Code
considerations
Context awareness
•   Configuration based on where the code has been
    deployed
•   Automatic
    • Automatic detection based on URL?
    • Environment variable set in vhost defintion?
•   Local configuration file
So whatʼs deployment
     all about?
Things to think about
• Transport to server
 • FTP? rsync? svn checkout? svn export?
• File permissions
• Preserve user uploaded files
• Steps after upload
 •   Stale cache?
 •   Cache priming?
Server organisation
• Much easier if you control vhosts
• For multiple sites on same server:
 •   Use predictable file locations for all sites
 •   e.g:
     •  /home/www/{site name}/live/current
     • /home/www/{site name}/staging/current
• Multiple servers for one site:
 •   Keep them the same!
The deployment plan
Typical steps
• Tag this release
• Set “under maintenance” page
• Transfer files to server
• Set file permissions as required
• Delete old cache files
• Run database migrations if required
• Remove “under maintenance” page
Hereʼs mine:
1. Branch trunk to release-{yymmdd-hhmm}
2. ssh into server
3. Ensure staging is up to date (svn st -u)
  If not, stop here!
4. svn checkout new release branch to a new
   folder in live directory
5. Set permissions on the /tmp folder for cache
   files
Finally
• Switch “current” symlink to new directory
Tools for automation
Simple scripts
• PHP, Bash or Bat files
• Simple to write and run
• Execute command line apps via exec()
Example PHP script
$cmd = "svn cp -m "Tag for automatic deployment"
    $baseUrl/$website/trunk $baseUrl/$website/tags/$date";

ob_start();
system($cmd, $returnValue);
$output = ob_get_clean();

if (0 < $returnValue) {
    throw new Exception("Tagging failed.n" . $output);
}
echo "Tagged to $daten";
Phing
• PHP based build system based on Ant
• XML configuration files
• PEAR installation
• Integration with Subversion and DbDeploy
• Expects to run build.xml in current directory
• build.properties contains config info
Phing philosophy"
• Like make, build scripts consist of targets
• Targets can depend on other targets
 • “live” depends on “tag”, “checkout”, “migrate”
• Each target does the minimum it can
  e.g.
  •   Create svn tag
  •   checkout files to destination
  •   migrate database
Example build.xml
<?xml version="1.0" encoding="UTF-8" ?>
<project name="BRIBuild" default="deploy" basedir=".">
  <tstamp>
    <format property="date" pattern="%Y%m%d-%H%M" />
  </tstamp>
  <property file="build.properties" />
  <property name="trunkpath" value="${svnpath}/${website}/trunk" />
  <property name="tagpath"
        value="${svnpath}/${website}/tags/${date}" />

  <target name="deploy" depends="tag" />
  <target name="tag" description="Tag trunk">
    <exec command="svn cp -m 'Tag for automatic deployment'
           ${trunkpath} ${tagpath}" />
    <echo msg="Tagged trunk to ${date}" />
  </target>
</project>
My deployment system
deploy.php
~$ deploy.php 23100
BRI server side deploy script
Version 1.1, 2009

Found /home/domains/bigroom/live/
Tagging to 20091030-2303... done
Deploying 20091030-2303 ... done
Changing symlink to new checkout
Cleaning up older checkouts
23100 successfully deployed to /home/domains/bigroom/live/
Our server layout
deploy.php
• Custom PHP script
• Relies on environment variable: WWW_DIR
• Advantages:
 •   Custom designed to fit our way of working
 •   PHP! Quick and easy to write.
• Disadvantages:
 •   Hard to alter for a specific server
 •   Hard to change methodology
FTP using Phing (1)
<project name="project" basedir="." default="deploy">
  <property file="build.properties" />
  <property name="trunkpath"
      value="${svnpath}/${website}/trunk" />
  <fileset dir="${exportdir}/" id="files">
    <include name="**/*" />
  </fileset>

  <target name="deploy" depends="svnexport,ftp-upload" />

  <target name="svnexport">
    <delete dir="${exportdir}" />
     <svnexport
        username="${username}" password="${password}"
        nocache="true" force="true"
        repositoryurl="${trunkpath}" todir="${exportdir}" />
  </target>
FTP using Phing (2)
  <target name="ftp-upload">
    <echo msg="Deploying application files" />
    <ftpdeploy
      host="${ftp.host}" port="${ftp.port}"
      username="${ftp.username}" password="${ftp.password}"
      dir="${ftp.dir}">
      <fileset refid="${files}" />
    </ftpdeploy>
  </target>

</project>
FTP with Phing
• Per-website build.xml for custom deployments
• Advantages:
 •   Leverages other peopleʼs experiences
 •   Was very fast to create
 •   Works where ssh not available!
• Disadvantages:
 •   New technology to be learnt
 •   Phing beta and Pear_Version_SVN alpha
Rollback
Emergency roll-back

Just change the symlink!
Complete roll-back
• Write rollback.php or create a Phing build
  task

• Put the server back to where it was before
 •   Change the symlink
 •   Delete the deployed directory
• Database rollback
 •   Run down() delta in your migration tool
To summarise

1. Automated deployment prevents mistakes
2. Itʼs not hard
3. Easy roll-back is priceless
Questions?
      feedback: http://joind.in/2842
          email: rob@akrabat.com
                  twitter: @akrabat
Thank you
      feedback: http://joind.in/2842
          email: rob@akrabat.com
                  twitter: @akrabat

Weitere ähnliche Inhalte

Was ist angesagt?

Test-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefTest-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefMichael Lihs
 
Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014Michael Lihs
 
Local development environment evolution
Local development environment evolutionLocal development environment evolution
Local development environment evolutionWise Engineering
 
Mitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpMitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpOntico
 
Automate your Development Environment with Vagrant & Chef
Automate your Development Environment with Vagrant & ChefAutomate your Development Environment with Vagrant & Chef
Automate your Development Environment with Vagrant & Chef Michael Lihs
 
Vagrant, Chef and TYPO3 - A Love Affair
Vagrant, Chef and TYPO3 - A Love AffairVagrant, Chef and TYPO3 - A Love Affair
Vagrant, Chef and TYPO3 - A Love AffairMichael Lihs
 
Introduction to selenium_grid_workshop
Introduction to selenium_grid_workshopIntroduction to selenium_grid_workshop
Introduction to selenium_grid_workshopseleniumconf
 
Continuous Delivery and Infrastructure as Code
Continuous Delivery and Infrastructure as CodeContinuous Delivery and Infrastructure as Code
Continuous Delivery and Infrastructure as CodeSascha Möllering
 
April, 2021 OpenNTF Webinar - Domino Administration Best Practices
April, 2021 OpenNTF Webinar - Domino Administration Best PracticesApril, 2021 OpenNTF Webinar - Domino Administration Best Practices
April, 2021 OpenNTF Webinar - Domino Administration Best PracticesHoward Greenberg
 
Leveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsLeveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsMark Niebergall
 
Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016Alan Lok
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsPablo Godel
 
How Ansible Makes Automation Easy
How Ansible Makes Automation EasyHow Ansible Makes Automation Easy
How Ansible Makes Automation EasyPeter Sankauskas
 
London Community Summit - Habitat 2016
London Community Summit - Habitat 2016London Community Summit - Habitat 2016
London Community Summit - Habitat 2016Sarah Richards
 
Automated deployments using envoy by John Blackmore
Automated deployments using envoy by John BlackmoreAutomated deployments using envoy by John Blackmore
Automated deployments using envoy by John BlackmoreTechExeter
 
ITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLIITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLIOrtus Solutions, Corp
 

Was ist angesagt? (20)

Test-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefTest-Driven Infrastructure with Chef
Test-Driven Infrastructure with Chef
 
Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014
 
Local development environment evolution
Local development environment evolutionLocal development environment evolution
Local development environment evolution
 
Mitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorpMitchell Hashimoto, HashiCorp
Mitchell Hashimoto, HashiCorp
 
Automate your Development Environment with Vagrant & Chef
Automate your Development Environment with Vagrant & ChefAutomate your Development Environment with Vagrant & Chef
Automate your Development Environment with Vagrant & Chef
 
Vagrant, Chef and TYPO3 - A Love Affair
Vagrant, Chef and TYPO3 - A Love AffairVagrant, Chef and TYPO3 - A Love Affair
Vagrant, Chef and TYPO3 - A Love Affair
 
Introduction to selenium_grid_workshop
Introduction to selenium_grid_workshopIntroduction to selenium_grid_workshop
Introduction to selenium_grid_workshop
 
Continuous Delivery and Infrastructure as Code
Continuous Delivery and Infrastructure as CodeContinuous Delivery and Infrastructure as Code
Continuous Delivery and Infrastructure as Code
 
Ansible - A 'crowd' introduction
Ansible - A 'crowd' introductionAnsible - A 'crowd' introduction
Ansible - A 'crowd' introduction
 
Command box
Command boxCommand box
Command box
 
April, 2021 OpenNTF Webinar - Domino Administration Best Practices
April, 2021 OpenNTF Webinar - Domino Administration Best PracticesApril, 2021 OpenNTF Webinar - Domino Administration Best Practices
April, 2021 OpenNTF Webinar - Domino Administration Best Practices
 
Ansible
AnsibleAnsible
Ansible
 
Leveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsLeveraging Composer in Existing Projects
Leveraging Composer in Existing Projects
 
Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016Ansible + WordPress - WordCamp Toronto 2016
Ansible + WordPress - WordCamp Toronto 2016
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
 
How Ansible Makes Automation Easy
How Ansible Makes Automation EasyHow Ansible Makes Automation Easy
How Ansible Makes Automation Easy
 
London Community Summit - Habitat 2016
London Community Summit - Habitat 2016London Community Summit - Habitat 2016
London Community Summit - Habitat 2016
 
Automated deployments using envoy by John Blackmore
Automated deployments using envoy by John BlackmoreAutomated deployments using envoy by John Blackmore
Automated deployments using envoy by John Blackmore
 
Learning chef
Learning chefLearning chef
Learning chef
 
ITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLIITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLI
 

Andere mochten auch

Sean coates fifty things and tricks, confoo 2011
Sean coates fifty things and tricks, confoo 2011Sean coates fifty things and tricks, confoo 2011
Sean coates fifty things and tricks, confoo 2011Bachkoutou Toutou
 
Connecting web Applications with Desktop, confoo 2011
Connecting web Applications with Desktop, confoo 2011Connecting web Applications with Desktop, confoo 2011
Connecting web Applications with Desktop, confoo 2011Bachkoutou Toutou
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Bachkoutou Toutou
 
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011Bachkoutou Toutou
 
Building APIs with Apigilty and Zend Framework 2
Building APIs with Apigilty and Zend Framework 2Building APIs with Apigilty and Zend Framework 2
Building APIs with Apigilty and Zend Framework 2David Stockton
 
Making php see, confoo 2011
Making php see, confoo 2011 Making php see, confoo 2011
Making php see, confoo 2011 Bachkoutou Toutou
 

Andere mochten auch (7)

Sean coates fifty things and tricks, confoo 2011
Sean coates fifty things and tricks, confoo 2011Sean coates fifty things and tricks, confoo 2011
Sean coates fifty things and tricks, confoo 2011
 
Connecting web Applications with Desktop, confoo 2011
Connecting web Applications with Desktop, confoo 2011Connecting web Applications with Desktop, confoo 2011
Connecting web Applications with Desktop, confoo 2011
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011
 
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011
Kill bottlenecks with gearman, sphinx, and memcached, Confoo 2011
 
Building APIs with Apigilty and Zend Framework 2
Building APIs with Apigilty and Zend Framework 2Building APIs with Apigilty and Zend Framework 2
Building APIs with Apigilty and Zend Framework 2
 
Making php see, confoo 2011
Making php see, confoo 2011 Making php see, confoo 2011
Making php see, confoo 2011
 
Technological and Mobility Trends in e-Government
Technological and Mobility Trends in e-GovernmentTechnological and Mobility Trends in e-Government
Technological and Mobility Trends in e-Government
 

Ähnlich wie Stress Free Deployment - Confoo 2011

WordPress Development Environments
WordPress Development Environments WordPress Development Environments
WordPress Development Environments Ohad Raz
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefNathen Harvey
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance DrupalJeff Geerling
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for DevelopmentChris Tankersley
 
Apex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEXApex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEXSergei Martens
 
Setting up a local WordPress development environment
Setting up a local WordPress development environmentSetting up a local WordPress development environment
Setting up a local WordPress development environmentZero Point Development
 
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...Nagios
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityGeoff Harcourt
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009Jason Davies
 
CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...
CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...
CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...E. Camden Fisher
 
Preparing your dockerised application for production deployment
Preparing your dockerised application for production deploymentPreparing your dockerised application for production deployment
Preparing your dockerised application for production deploymentDave Ward
 
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014Miguel Zuniga
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionJoe Ferguson
 
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...Nagios
 
Automating Web Application Deployment
Automating Web Application DeploymentAutomating Web Application Deployment
Automating Web Application DeploymentMathew Byrne
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworksKirk Madera
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 

Ähnlich wie Stress Free Deployment - Confoo 2011 (20)

WordPress Development Environments
WordPress Development Environments WordPress Development Environments
WordPress Development Environments
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance Drupal
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for Development
 
Apex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEXApex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEX
 
Setting up a local WordPress development environment
Setting up a local WordPress development environmentSetting up a local WordPress development environment
Setting up a local WordPress development environment
 
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production Parity
 
Hosting Ruby Web Apps
Hosting Ruby Web AppsHosting Ruby Web Apps
Hosting Ruby Web Apps
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009
 
CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...
CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...
CT Software Developers Meetup: Using Docker and Vagrant Within A GitHub Pull ...
 
Preparing your dockerised application for production deployment
Preparing your dockerised application for production deploymentPreparing your dockerised application for production deployment
Preparing your dockerised application for production deployment
 
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
Configuration Management in the Cloud - Cloud Phoenix Meetup Feb 2014
 
PHP Rocketeer
PHP RocketeerPHP Rocketeer
PHP Rocketeer
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
 
Automating Web Application Deployment
Automating Web Application DeploymentAutomating Web Application Deployment
Automating Web Application Deployment
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworks
 
Evolution of deploy.sh
Evolution of deploy.shEvolution of deploy.sh
Evolution of deploy.sh
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 

Mehr von Bachkoutou Toutou

hacking your website with vega, confoo2011
hacking your website with vega, confoo2011hacking your website with vega, confoo2011
hacking your website with vega, confoo2011Bachkoutou Toutou
 
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011Bachkoutou Toutou
 
Connecting Web Application and Desktop, confoo 2011, qafoo
Connecting Web Application and Desktop, confoo 2011, qafooConnecting Web Application and Desktop, confoo 2011, qafoo
Connecting Web Application and Desktop, confoo 2011, qafooBachkoutou Toutou
 
99 problems but the search aint one, confoo 2011, andrei zmievski
99 problems but the search aint one, confoo 2011, andrei zmievski99 problems but the search aint one, confoo 2011, andrei zmievski
99 problems but the search aint one, confoo 2011, andrei zmievskiBachkoutou Toutou
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick RethansBachkoutou Toutou
 
WebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coatesWebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coatesBachkoutou Toutou
 
Confoo 2011 - Advanced OO Patterns
Confoo 2011 - Advanced OO PatternsConfoo 2011 - Advanced OO Patterns
Confoo 2011 - Advanced OO PatternsBachkoutou Toutou
 

Mehr von Bachkoutou Toutou (9)

hacking your website with vega, confoo2011
hacking your website with vega, confoo2011hacking your website with vega, confoo2011
hacking your website with vega, confoo2011
 
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011
Premiers pas dans les extensions PHP, Pierrick Charron, Confoo 2011
 
Connecting Web Application and Desktop, confoo 2011, qafoo
Connecting Web Application and Desktop, confoo 2011, qafooConnecting Web Application and Desktop, confoo 2011, qafoo
Connecting Web Application and Desktop, confoo 2011, qafoo
 
99 problems but the search aint one, confoo 2011, andrei zmievski
99 problems but the search aint one, confoo 2011, andrei zmievski99 problems but the search aint one, confoo 2011, andrei zmievski
99 problems but the search aint one, confoo 2011, andrei zmievski
 
Php Inside - confoo 2011 - Derick Rethans
Php Inside -  confoo 2011 - Derick RethansPhp Inside -  confoo 2011 - Derick Rethans
Php Inside - confoo 2011 - Derick Rethans
 
WebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coatesWebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coates
 
Apc Memcached Confoo 2011
Apc Memcached Confoo 2011Apc Memcached Confoo 2011
Apc Memcached Confoo 2011
 
Xdebug confoo11
Xdebug confoo11Xdebug confoo11
Xdebug confoo11
 
Confoo 2011 - Advanced OO Patterns
Confoo 2011 - Advanced OO PatternsConfoo 2011 - Advanced OO Patterns
Confoo 2011 - Advanced OO Patterns
 

Kürzlich hochgeladen

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Kürzlich hochgeladen (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Stress Free Deployment - Confoo 2011

  • 1. twitter: @akrabat Stress-free Deployment Rob Allen ConFoo March 2011
  • 2. Rob Allen? • PHP developer since 1999 • Wrote Zend_Config • Tutorial at akrabat.com • Zend Framework in Action! Next book! Zend Framework 2 in Action (with Ryan Mauger)
  • 6. Branch! • Branch every new feature • (that includes bug fixes) • Be ready go live at all times • Trunk deployment • Live branch deployment
  • 11. One master database • Live database holds master structure • Copy master to everywhere else • Advantages: • Simple to implement • Disadvantages: • Backwards compatibility required • Doesnʼt scale for multiple devs well • Easy to make mistakes
  • 12. Migrations • Versioned schemas • Use delta files with UP and DOWN functions • Advantages: • version controlled • destructive changes possible (but donʼt do it!) • Disadvantages: • Canʼt think of any!
  • 13. Migrations tools • DbDeploy • LiquiBase • Framework specific • Doctrine • Akrabat_Db_Schema_Manager • Cake migrations • PEAR: MDB2_Schema • Home-brew script
  • 14. For more info “Database version control without the pain” by Harrie Verveer http://slidesha.re/gwq0aw Also read http://www.harrieverveer.com/?p=247
  • 16. Context awareness • Configuration based on where the code has been deployed • Automatic • Automatic detection based on URL? • Environment variable set in vhost defintion? • Local configuration file
  • 17. So whatʼs deployment all about?
  • 18. Things to think about • Transport to server • FTP? rsync? svn checkout? svn export? • File permissions • Preserve user uploaded files • Steps after upload • Stale cache? • Cache priming?
  • 19. Server organisation • Much easier if you control vhosts • For multiple sites on same server: • Use predictable file locations for all sites • e.g: • /home/www/{site name}/live/current • /home/www/{site name}/staging/current • Multiple servers for one site: • Keep them the same!
  • 21. Typical steps • Tag this release • Set “under maintenance” page • Transfer files to server • Set file permissions as required • Delete old cache files • Run database migrations if required • Remove “under maintenance” page
  • 22. Hereʼs mine: 1. Branch trunk to release-{yymmdd-hhmm} 2. ssh into server 3. Ensure staging is up to date (svn st -u) If not, stop here! 4. svn checkout new release branch to a new folder in live directory 5. Set permissions on the /tmp folder for cache files
  • 23. Finally • Switch “current” symlink to new directory
  • 25. Simple scripts • PHP, Bash or Bat files • Simple to write and run • Execute command line apps via exec()
  • 26. Example PHP script $cmd = "svn cp -m "Tag for automatic deployment" $baseUrl/$website/trunk $baseUrl/$website/tags/$date"; ob_start(); system($cmd, $returnValue); $output = ob_get_clean(); if (0 < $returnValue) { throw new Exception("Tagging failed.n" . $output); } echo "Tagged to $daten";
  • 27. Phing • PHP based build system based on Ant • XML configuration files • PEAR installation • Integration with Subversion and DbDeploy • Expects to run build.xml in current directory • build.properties contains config info
  • 28. Phing philosophy" • Like make, build scripts consist of targets • Targets can depend on other targets • “live” depends on “tag”, “checkout”, “migrate” • Each target does the minimum it can e.g. • Create svn tag • checkout files to destination • migrate database
  • 29. Example build.xml <?xml version="1.0" encoding="UTF-8" ?> <project name="BRIBuild" default="deploy" basedir="."> <tstamp> <format property="date" pattern="%Y%m%d-%H%M" /> </tstamp> <property file="build.properties" /> <property name="trunkpath" value="${svnpath}/${website}/trunk" /> <property name="tagpath" value="${svnpath}/${website}/tags/${date}" /> <target name="deploy" depends="tag" /> <target name="tag" description="Tag trunk"> <exec command="svn cp -m 'Tag for automatic deployment' ${trunkpath} ${tagpath}" /> <echo msg="Tagged trunk to ${date}" /> </target> </project>
  • 31. deploy.php ~$ deploy.php 23100 BRI server side deploy script Version 1.1, 2009 Found /home/domains/bigroom/live/ Tagging to 20091030-2303... done Deploying 20091030-2303 ... done Changing symlink to new checkout Cleaning up older checkouts 23100 successfully deployed to /home/domains/bigroom/live/
  • 33. deploy.php • Custom PHP script • Relies on environment variable: WWW_DIR • Advantages: • Custom designed to fit our way of working • PHP! Quick and easy to write. • Disadvantages: • Hard to alter for a specific server • Hard to change methodology
  • 34. FTP using Phing (1) <project name="project" basedir="." default="deploy"> <property file="build.properties" /> <property name="trunkpath" value="${svnpath}/${website}/trunk" /> <fileset dir="${exportdir}/" id="files"> <include name="**/*" /> </fileset> <target name="deploy" depends="svnexport,ftp-upload" /> <target name="svnexport"> <delete dir="${exportdir}" /> <svnexport username="${username}" password="${password}" nocache="true" force="true" repositoryurl="${trunkpath}" todir="${exportdir}" /> </target>
  • 35. FTP using Phing (2) <target name="ftp-upload"> <echo msg="Deploying application files" /> <ftpdeploy host="${ftp.host}" port="${ftp.port}" username="${ftp.username}" password="${ftp.password}" dir="${ftp.dir}"> <fileset refid="${files}" /> </ftpdeploy> </target> </project>
  • 36. FTP with Phing • Per-website build.xml for custom deployments • Advantages: • Leverages other peopleʼs experiences • Was very fast to create • Works where ssh not available! • Disadvantages: • New technology to be learnt • Phing beta and Pear_Version_SVN alpha
  • 39. Complete roll-back • Write rollback.php or create a Phing build task • Put the server back to where it was before • Change the symlink • Delete the deployed directory • Database rollback • Run down() delta in your migration tool
  • 40. To summarise 1. Automated deployment prevents mistakes 2. Itʼs not hard 3. Easy roll-back is priceless
  • 41. Questions? feedback: http://joind.in/2842 email: rob@akrabat.com twitter: @akrabat
  • 42. Thank you feedback: http://joind.in/2842 email: rob@akrabat.com twitter: @akrabat