This is one of those things that I know all the experiences web developers do but I haven’t taken the time to figure it out yet. I think it’s time.
What techniques do you guys use for deploying (or updating) your applications to external web hosts?
This is what I have always done, which pretty much sucks:
SVN Commit via TortoiseSVN (~6 seconds of clicking around)
SVN Export via TortoiseSVN (~15 seconds of clicking around)
Open FileZilla (3 seconds)
Upload exported files, with "Export if source newer" option (10 seconds)
This all adds up to a half a minute. Sometimes I do this 10 times a day. I hate doing it. I don’t even take the site down usually when performing the update. Not good
It seems I could create a script to automate all of this, so all I have to do is run it and bam the site updates to my local copy.
I am looking for advice for the best way to set this up. I’ve done some googling and it seems there are a whole bunch of options, so many I don’t know where to start.
What I would like:
Only changed or new files should be uploaded to the server, that are under version control. No need to re-upload the whole thing each time
Scripts to take down and up the site to run before doing maintenance (could be as simple as uploading an alternate index.php file).
What I think I need:
FTP software that can be run from command line (what is good?)
Figure out how to use version control from command line
What methods have you guys gone about? Any examples out there? It seems the script could be written in pretty much any language including php.
I am using windows. It seems that most examples on the web are directed towards linux which I really don’t know much about.
I’m going to play around but I was wondering if anyone had any starting advice before I try something out which turns out to be a bad method
We are using "svn update" to deploy. It usually happens that you may find bugs or add new features after the system is deployed for the first time. Then you will appreciate how convenient "svn update" is. To make it safer, you could use svn branches to make sure you only "svn update" on the production server when you think the code is stable enough.
Ah yes this solution did cross my mind. Is this possible on a shared host however?
Just did some googling and it seems to get it working I first need to learn how to connect to the server with SSH. So it is possible. So I’m going to do some playing around with that. You pointed me in the right direction. Thanks!
EDIT: just got putty/ssh working on dreamhost. This is cool stuff… svn is already installed
EDIT2: OK it seems like its gonna work on my other host too. This is gonna save a lot of time
I’ve never heard of mounting a server as a remote drive… just googled it and it sounds pretty nifty/cool. I like using svn update as apposed to copying the files over as it takes less time for the server to do, as it only sends the file changes.
I just checked if the .svn folders were accessible and luckily they are not (for whatever reason).
I use plink (command line version of putty) to deploy the application via a .bat file (one click!). I am also planing on creating .bat files to bring up and down the server for public use (by replacing index.php probably).
I hear git has a lot of improvements over svn so I hope to learn it someday when I have time…
For updating the database, I have always just done it manually on the server phpMyAdmin script. Not the cleanest method… Whenever I made a change on my local database for testing, I would just jot down the sql that phpMyAdmin executed, then executed the same thing on the remote server phpMyAdmin once deploying. Haven’t needed to convert any data yet. So I’m going to try out this MySQL Workbench and see what it’s about…
I know, that everyone is knowing it, but i want to mention rsync for every non-svn/git/googlecode project around. Initial sync takes long (since it copies up ALL data) but after that, only the changes are ‘commited’ which makes it very fast ( way < 1 second )…
The beta of MySQL workbench seems to have a lot of bugs right now. For instance, after altering a table, the changes don’t show until I refresh my object explorer, and when I do that, I have to re-navigate to where I was. Besides the bugs it’s perty good tho
On all of my past projects I simply uploaded new/updated files via FTP without putting site offline or something. It worked well since the overall amount of files were always small. I’m looking forward to use a version control system to do the updates of new projects.
You guys know if there’s an offline svn/git/bazaar solution (maybe a bundle with webserver or something)? Because for now I work alone but I would still like to use versioning and then later put everything online so others can access.
Well that’s the good thing about Git, it is local, you can do as many commits you wish locally before you push it to your server (if you do push it to a server).