Setting up development/deploy/production -server

Posted September 10, 2014 10.7k views


My workflow today sucks and is no way good. So I have decided I would like to change how I work. And that is as follows: A vagrant box, for local development. With version control, using GIT. And then a development server running both git and a web server, and sql server. So a setup where I got. GIT, MySQL, PHP, Nginx and

  1. GIT repo setup on a development server (Found this great tutorial:

  2. A deploy script that on all commits would deploy to the development webroot for that GIT repo/project but with some hook or something.

  3. A deploy script to the production server, don’t know how to best trigger this, please come with advice and some tutorial on how to implement this.

  4. A production server, (All tutorials I read pretty much states, “This configuration should not be used in production. Only on development servers”) So some good tutorial on setting up a production server. Containing, MySQL, PHP and Nginx. E-mail support for PHP applications.

  5. And finally a happy life ;)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

I work in a similar way to how you want to do it. (Plus points for Vagrant BTW, it’s the ONLY way to develop locally!)

This is how I do it though....

  1. Get your production and development boxes setup in exactly the same way. LEMP is my recommendation on LEB such as the $5 DO box. Get them hardened and locked down. There are loads of good articles on here explaining how to setup your server and then configure UFW and F2B.
  2. Create your vagrant build as similar to the development and production servers as you can though.
  3. Setup your local files for your app / website / blog etc.
  4. Add your files and vagrant build to a new Git repo.
  5. Push this out to bitbucket (Github alternative with free private repos)
  6. Set up bare git repo’s on your production and development servers that are configured to run a post-commit hook to checkout to the sites directory.
  7. Develop and when you are ready to demonstrate to clients, coworkers etc. do a git push to ‘development’ / 'production’ to see it on the live servers.

On that note, vagrant share is a really good way to temporarily demonstrate work before you push to your development and ultimately production servers.

With regards to email on DO boxes, I would recommend using Mandrill or MailGun for convenience.

I have a number of sites setup with DO in this way and it serves the purpose.

Is it the dream development workflow? Probably not and there are a few alternatives each with their advantages and disadvantages. You could go down the Capistrano route or use rsync to push out files. Capistrano is probably more robust and has roll back capabilities, rsync is simpler and quicker to setup.

My advice is to experiment with each system and refine the process to suit your needs. Good luck.

  • Thanks, yeah new to Vagrant but I like the idea of it. Have not had that much of time to use or test it.

    Going to use the $10 DO Box, but what does LEB stand for? All I found find was some kind of Ubuntu distro-version but I guess its not what you mean as there is no option reflecting that when creating a new DO Droplet.

    But I would like to keep my code on my own servers and not use bitbucket/Github or anything like that. Think I will just setup a GIT-repository on my development server for daily use and then a git bare repo as you suggest for when I’m going to deploy to the server.

    I would then commit to 3 different GIT repos? One for my work and when ready to show it to friend/colleagues/customers what ever, I commit to the development repo that also have a git-post commit hook and the same on my production server that should have a git-repo that I can commit to when I want to make updates live.