Manual Website Deployment
Posted in Misc on August 17th, 2010 by helloworlder – Be the first to commentRegardless of what language your app is coded in there are some things that are common to pretty much all deployments. Deployment scripts such as capistrano and Ant are great but if you haven’t done a manual deployment before, jumping the gun to a full auto deploy can be pretty confusing. We’re not talking about opening up an FTP client and dragging your files onto the server, although there’s nothing to stop you from doing that. With simple static websites it’s OK, but doing that with any non-trivial web app this approach is very inefficient. The nightmarish file management practices alone is enough discouragement.
Imagine deploying a PHP/MySQL app onto a Linux Ubuntu VPS with SSH access and Apache running. These are the things I would do for a manual web deploy:
1. Set up an SVN repository on your web server. You cannot live without a version control system. If you’re progressive and using Git or Mercury, that’s great.
2. Commit your entire web app into the SVN repository - well actually you should be working and committing to a repo on day 1 of development. If you’re developing on Windows, TortoiseSVN is a good GUI client.
3. Most non-trivial web apps run a database. Assuming that you add data to the database during development, you need to keep the data “in sync” with the rest of your web app. It’s obvious yeah? - export the database into a file e.g. mydata.sql and commit it to the SVN repository with the rest of your web app, not placing it in a folder exposed to the public.
4. Log onto the server (using Putty if on Windows) via SSH, and navigate into the folder where your website is served. From there do an SVN checkout from your repository, which goes something like:
sudo svn co file:///home/helloworlder/repository/myproject trunk .
5. Create the database on your web server if you haven’t already. Or, if you already have the database with outdated data in it then drop it and create it again. Now, you just need to import the database (in our case a .sql file) that’s in your repository (step 3).
6. SVN metadata is served with the rest of the website, and you don’t want that. There are many ways to deal with this including using exports and not checkouts, but you can do this.
7. After doing all that many times over you might even start to get tired of it. Maybe write a script that does the svn checkout and database import in one fell swoop.

