WordPress Development
and Deployment Strategies
David McDonald
November 13, 2013
David McDonald
November 13, 2013
Creating a new website is as easy as adding a folder to your webserver root.
The virtual hosts are created automatically.
Install dnsmasq & setup. Easiest install is to use homebrew:
brew install dnsmasq
Modify your vhosts.conf file:
<VirtualHost *:80>
VirtualDocumentRoot /Users/[myusername]/Sites/%1/
ServerAlias %1.*
UseCanonicalName Off
<Directory "/Users/[myusername]/Sites">
Options Indexes FollowSymLinks Includes ExecCGI MultiViews
</Directory>
</VirtualHost>
Edit your Network preferences and add 127.0.0.1 above any other DNS server entries
To create a new WordPress site, copy the conf folder into your new site folder, then run:
wpbuildr [sitename]
Clone from github: https://github.com/AaronHolbrook/wpbuildr
git clone https://github.com/AaronHolbrook/wpbuildr.git [mydirectory]
Follow instructions there and customise as needed.
Some of the wpbuildr forks and pull requests are interesting to look at for ideas.
mu-plugins
directory inside the wp-content
folder and which are automatically enabled on all sites in the installation.Caveat: mu-plugins are not checked for updates by WP's auto update
To deploy a site to the testing server:
git push test
To deploy a site to the live server:
git push live
Set up an SSH alias for the site: in ~/.ssh/config
:
Host website-l Hostname www.website.com.au user gituser
Set up a bare git repo and the post-receive hook:
mkdir website.git && cd website.git git init --bare cat > hooks/post-receive #!/bin/sh GIT_WORK_TREE=~/www/wp-content/themes/[my theme name] git checkout -f chmod +x hooks/post-receive
Add a remote repo:
git remote add live website-l:~/website.git git push live +master:refs/heads/master
The remote repo lives in the ~/
of website-l
, so it's not accessible to the world
The post-receive hooks pushes the bare files to ~/www/wp-content/themes/[my theme name]
All the above can be scripted as part of setting up a new site, using wpbuildr.
I found the concept at http://toroid.org/ams/git-website-howto
You can view this presentation at http://www.dmcweb.com.au/wpmelb