Git Product home page Git Product logo

php-ha-multi-tier-app-cookbook's Introduction

(Deprecated) This repository was moved to https://github.com/haapp

PHP High Availability Multi Tier Application Chef Cookbook

(This guide is for PHP developers and system administrators without DevOps experience, yet assuming you know how to use Git)

These Cookbooks aims to keep and maintain consistent configuration between development server, stagnig server, and production server with ease and safety of operation and development in mind by installing and configuring following tiers of services:

**PXC is a MySQL Database enhanced with Galera multi-master replication library which enables PHP developer to utilize multiple database without differenciating DB-read code and DB-write code

A common cookbook for all servers enables following operations/features for all Servers easing day to day system administration work:

  • Linux users with ssh key access can be added, modified or removed at once in all VMs
  • Time zone and ntp can be configured at once
  • Monit with automatic restarting when service process dead, send email notification in such event via SMTP (optionally)
  • Newrelic Server Monitoring with custom configuration (optionally)

Pre Reqirements

Enable VT-x in Windows 8, in Windows 7

Install following DevOps tools:

in Windows cmd (Administrator) or ConEmu with Chocolatey:

C:\Users\John>choco install virtualbox -y
C:\Users\John>choco install vagrant -y
C:\Users\John>choco install chefdk -y

in Mac Terminal with Homebrew and Cask:

$ brew cask install virtualbox
$ brew cask install vagrant
$ brew cask install chefdk

in Ubuntu Terminal with apt-get:

$ sudo apt-get install virtualbox
$ sudo apt-get install vagrant
$ sudo apt-get install chefdk

PHP Development Workflow

**fllowing sections, subl command is used to launch Sublime Text as editor from command line to edit files

git clone https://github.com/joelhandwell/php-ha-multi-tier-app-cookbook.git
cd php-ha-multi-tier-app-cookbook
vagrant up

This will trigger Vagrant Chef Zero Provisioner to install HAProxy, Varnish, Apache HTTP, Memcached, PXC in one VM managed by Vagrant. Following Vagrant commands are available to shutdown(poweroff), delete, create/poweron, reconfigure (with chef) the development server:

vagrant halt
vagrant destroy
vagrant up
vagrant provision

make some page in automatically created VM's document root directory syncronized with host machine via Vagrant:

subl websites/examplewebsite.com/index.php

use HostAdmin for Chrome or for FireFox to point examplewebsite.com 192.168.33.10 which is Vagrant's private ip address

Open http://examplewebsite.com in browser to see the index.php is displayed. Change index.php, and refresh browser, developers do not need to use FTP to see changes, but changes are applied immediately in dev server when it's changed in host machine due to sync.

Cookbook Development Workflow

Create feature branch

git checkout -b feature

Write chefspec test, modify cookbook, and run test, repeat till pass

subl spec/w_common/default_spec.rb
subl cookbook/w_common/recipes/default.rb
chef exec rspec spec/w_common/default_spec.rb

if you passed chefspec test, write serverspec test

subl test/integration/test_w_common/serverspec/localhost/default_spec.rb

create and execute initial apply Chef cookbook onto VM

chef exec kitchen list
chef exec kitchen create common
chef exec kitchen setup common

if you get error, modify cookbook and apply Chef again

subl cookbook/w_common/recipes/default.rb
chef exec kitchen converge common

run serverspec

if it's executed without error, run serverspec test, and if test fail, edit cookbook until pass, and delete VM after pass, and run end to end test for make sure, and commit change.

subl cookbook/w_common/recipes/default.rb
chef exec kitchen converge common

subl cookbook/w_common/recipes/default.rb
chef exec kitchen converge common

chef exec kitchen destroy common
chef exec kitchen test common

git add cookbook/w_common/recipes/default.rb
git commit

php-ha-multi-tier-app-cookbook's People

Contributors

fulloflilies avatar joelhandwell avatar kenyu0807 avatar remaininme avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.