Prezi

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in the manual

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Techniques for Deploying PHP and MySQL

No description
by Michael Bopp on 24 March 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Techniques for Deploying PHP and MySQL

Entry Level / Default Setup
AKA: The Problem
The Big Idea
Techniques for Deploying PHP and MySQL
Establish a standard as to how Schemas will be named
<project>_local
<project>_dev
<project>_review
<project>_prod
Site Configuration IN CODE when possible

Not in Database, as it need to remain "portable" between environments.
I prefer Standard Bash scripts
But other scripting languages work as well
Perl
Ruby
Python
etc

Standardizing to
Make the tasks more accessible to everyone
Maintain Consistency
Prevent Errors
Tools include
Capistrano
Whiskey Disk
Chef
Jenkins
Leveraging Branches
(or tags)
Post commit
Doesn’t necessarily require configuration in the Shell
Keep separation between MySQL and the PHP code.

It's like Dependency Injection, but far more simplistic.

Just because PHP and MySQL are more accessible to beginners, doesn't mean more advanced techniques introduced by other frameworks can't be used.
PHP & MySQL
The glue that make things happen
Scripting
Version Control
Leveraging Hooks
Shell Scripting
Tools / GUIs
MySQL Naming Conventions
Database Settings
Michael Bopp - @mwbopp
PHP & MySQL (obviously)
Scripting
Version Control
SSH
Communication Medium
Devops Deployment Toolkit
SSH
Communication Medium
Websites
Email
Logs
ssh-keygen -t rsa

cat ~/.ssh/id_rsa.pub | ssh user@host.com "cat >> ~/.ssh/authorized_keys"
Authorized Keys
Most popular SAS applications provide hooks and other APIs.

Asana
Harvest
Basecamp
Pivitol Tracker
Slack
Project Management
The Big Idea
Environment Structure & Layout
(s)FTP
A Better Setup
Dev
Review
Production
Can be used alongside the environment specific scheme
Git Branching Model
Get Comfortable

Very, Very Comfortable
Keep all activity in the Light
Maintain different configuration files (in PHP or other syntax) for each environment.

After moving code from one environment to another, link up the correct configuration file.
Symlinks
settings.
dev
.php
Code Pattern
Check for Current Environment

Scan site code for the correct pattern. *.
<env>
.*

Link to environment specific file

ln -s settings.dev.php settings.php
Use your SCM solution to keep environment code separate and manage where the checkout will live.
ENV=dev

for f in $( find . -name "*.$ENV.*" ); do
NEWFILE=${f//.$ENV./.}
OLDFILE=$(basename "$f")
echo "Symlinking: ln -s $OLDFILE $NEWFILE"
rm $NEWFILE 2>&1
ln -s $OLDFILE $NEWFILE 2>&1
done # matching files
Shell Script Example
mysqldump -u
user
-p
pass
orig_db > db_dumpfile.sql

mysql -u
user
-p
pass
new_db < db_dumpfile.sql
Moving a Database
master
review
dev
settings.local.php
settings.dev.php
settings.review.php
settings.prod.php
See the full transcript