Posted at September 01, 2012
My VPS is my ‘live server’, it runs all my production code on the internet. But I develop locally on my laptop using XAMPP. For most of my projects I use Git as a version control system while storing it on Github.
So the infrastructure looks like:
laptop -> Github -> vps
dev version control production
working copy repo working copy
Everytime I make some changes to my code I commit them to Github:
git commit -a
When it’s time to deploy an update I only have to get the latest changes from Github:
Working with sensitive files (passwords)
Most of the time I work with either node.js scripts or PHP files. They both have an option to include an additional file. I use this to include config files that need to stay private outside of the app:
var sql = require( '/config/app/sql.js' );
This also solves the problem of having different configuration (passwords, security) on your production server as well as on your development server. You will have to copy those files over by hand, but only once per new app.
Automatically apply the changes
When I start on a new website I use the HTML5Boilerplate and the build script as a starting point. The build script automatically takes care of a lot of front-end optimisation like minifying and concatenating JS and CSS, add caching and the versioning of filenames.
I read this little trick somewhere, but I can’t remember where
To deploy a new site this way I just have to run:
git pull && cd build && ant build
This will pull the latest version of Github and run the build script.
If you have node.js scripts running for a long time you can use something like
supervisor to make sure the script keeps running. The latter also watches for file changes. So if you pull the latest Github version of your app, supervisor will reload the script for you.