#109: Getting off FTP and onto Git Deployment with Beanstalk
In this screencast I move my own personal website from my old live FTP editing ways to a proper version controlled system including deployment. I haven't had much experience with this, so forgive me if it's a bit rough.
We start by moving the live website local, including bringing all the files down and copying the database. Then we set up a Git repository in Beanstalk and push it all up to that. Then we give Beanstalk our FTP credentials and set up how we want deployment done. Then we make some local changes to our site, and commit/push them to Beanstalk, which does the deployment for us. By then end, it's all working perfectly.
If you've got questions/comments/suggestions on this workflow, I'd love to hear!
Links from the video:
- Coda
- WordPress
- Plesk / phpMyAdmin
- ChrisCoyier.net / MediaTemple
- Sequel Pro
- Sublime Text 2
- Beanstalk
- MAMP / MAMP Screencast [1] [2]
- Git Tower / GitHub Screencast
Followup:
Mark Jaquith on Working with WordPress Locally (specifically, dealing with plugins and config).
Running Time: 25:57
Perfect timing! I was just setting this up when I saw your tweet. Thanks. :)
Same here :)
Thanks for this screencast, Chris!
We use beanstalk for handling the theme development at the new kid in town, MonsterThemes. And I love it.
Coda has nice integration with Beanstalk. I’ve been using it for about six months with no problems at all.
That’d be SVN though, right? Which is totally fine. Personally I don’t use all of the fancy Git has to offer anyway. And Coda 2 is right around the corner I think and MIGHT have Git? Not sure. I think it would be weird if it didn’t.
I see youo’r eusing SublimeText2 on the screencast, there is a TortoiseGit extension for it. I currently use it and it works just fine for the basic git stuff needed. Have you tried it ? http://wbond.net/sublime_packages/tortoise
How do you manage database changes? Do you any easy way for that?
For WordPress, you could look into: http://crowdfavorite.com/wordpress/ramp/
Otherwise I don’t have a good solution. It’s one of those things I don’t think there are perfect answers for yet.
I’ve not had many projects where I would be nice to have database versioning too. With normal WordPress themes, create a theme-centric repo would work fine.
There isn’t really a good solution for this yet. RAMP does content addition, but more complex changes aren’t supported. What I recommend is that you script the changes you want to make, using the WordPress APIs (PHP, not the remote APIs). Get it working locally, on a fresh DB snapshot, then commit it, deploy it, and run it on production.
That weird thing with MAMP was because it started another mysql process ( beats the hell out of my as to why it does that but it does…) all you have to do when that happens is: go to your utilities folder, open activity monitor, find mysql (there probably will be two or three… ) and stop them.
After that you just tell MAMP to start the servers again and it should work :D
Great screencast by the way loved it
I’m surprised how often I have to do this.
I love how Chris is willing to “do it live” and still share with all of you. Awesome job.
If anyone has questions about Beanstalk’s deployment tools (or anything else Beanstalk specific, drop me a comment and I can help you out.
-Alex
wildbit.com
Thank you for the introduction to beanstalk and git.
I would like to request an extended vs. of the tutorial on how to properly setup staging deployments and best practices for setting up multiple repositories for each theme/plugin etc.
I am new to beanstalk and git, but it makes sense to me that I might not want to necessarily push directly to my live site, but more to a staging site first to make sure all is perfect before going live. (also it would give me benefit of a backup site just in case)
Finally the best practice of using multiple repositories would be nice. That way I could update the WordPress core without messing around with my theme files etc.
*One thing am learning quickly is that Windows is nowhere near as nice as the apple when it comes to these apps. Can’t find anything nearly as nice as Tower for windows, closest seems to be Smartgit, would love suggestions on apps for Windows in the meantime.
Great screencast, Chris.
I haven’t really seen the appeal of SVN or Git in isolation, and have always thought that what was missing was a method of integrated deployment, which has always left me in the just-do-FTP camp (although I do use a local copy, so I’m not completely ‘commando’, as you put it). It’s very nice to see how it can now all hang together (stubborn MAMP notwithstanding!). Surely though it doesn’t have to be this complicated, and future products (like Coda, as you suggest in an earlier comment) will offer a smoother all-in-one interface. I can imagine a single service that has both a local app for editing and committing, and also a web-based service like BeanStalk as one complete offering. Let’s hope someone comes up with a simpler solution soon.
Did you have several coffees before making this? I felt like I needed to watch it at a slower speed! :-)
@ChrisCoyier
What is the password manager called that you used in Chrome?
1Password
I’m getting my beanstalk set up right now. Awesome! I’ve been trying to figure out how I could do things locally for such a long time. Thank you!
And thank you for having the best sense of humor, too. I get almost as much pure entertainment value out of these screencasts as I do learning value. :)
Adding in LiveReload to the mix would complete the cycle. Are you still using that in this current setup?
Thanks again. :)
I like LiveReload but I’m on CodeKit now. Will do screencast on that as soon as I can.
Ugh! I’m getting a “The path already contains a git repository” error…
No matter what path I choose, that’s what I get.
Any clues?
Very weird… I figured out what the problem was. When I was using Tower to create my local path, it would tell me that a git repo was already there. Only when I manually created a new directory would it work the way demoed on in your screencast.
Just an FYI in case someone else runs into this issue.
I’m about to but into beanstalk, this is WAY powerful and awesome.
I found this tutorial by Jeffrey Way useful to understand how tower works, he’s using a beta version, but the concepts still apply:
http://net.tutsplus.com/tutorials/other/quick-tip-first-look-at-the-git-tower-gui/
I’m up and running with beanstalk (free account for now) and git tower. I like the workflow a lot and I feel like I’m starting to understand the purpose of branches and merging etc.
I still have a couple of questions:
1. Auto deployment in beanstalk is not working for me. Is this because I’m on a free account?
2. To revert to an earlier version in tower git should I be using “revert to this commit” or “roll back to this commit” ? I’m getting a bunch of errors when trying to go back up to the latest version after reverting down to a previous version.
Hi Paul,
Deployments is included in all paid accounts, but not the trial plans, sorry.
If you haven’t already, email Beanstalk support. We can help you with those errors.
Great run through for people new to GIT. You might like Magic Bean for Mac to deploy sites straight from your Mac’s Status bar through Beanstalk. Useful for those manual deployments to live environments. :)
http://www.magicbeanapp.com/
Andy
Does anybody know of something that would work like beanstalk, but free (basically multiple free repositories).
It’s only free for a single repository, but it’s great! Try springloops.com
Does anybody know of something that would work like beanstalk, but free (basically multiple free repositories)?
you can use Assembla.com for free private repos. then you can use capistrano for deploying via SSH. Better than using FTP.
initial setup is a bit convoluted, but once that’s done, adding new sites is quite straightforward.
Hello,
Thanks for the video.
I noticed that you created a new folder/repo, and later copy into the new from the old. I would recommend that you just init a new repo in the exisiting folder, and then add the Beanstalk as a remote. That way I believe it just just to add this into Tower as an existing repo.
This is more for the command-line lovers like myself. But it does get the work done, and I’m sure it can we done with Tower as well. That way you remove the copy step :)
Good luck with Git! I love it.
Great s-cast!!
Would love to see another git episode with push/pulls from 2 people working on same site as is often the case.
Keep up the great work!
You rule Chris, I was actually doing this setup.
Thanks a million man, I was trying to figure this out for a week.
@Chris,
First thank you for all your screencasts, they are great!
I am fairly new to Git as well. I am NOT a programmer by any means just a front-end developer, but after learning the basics of what I need to know to use it through ssh and cmd line (terminal/bash/etc) I would never use all the applications you used in this screencast. It seems like 4 times the work and 4 times the amount of time as well. Even though, great screencast for getting people started with some type of versioning.
Chris, I laughed so hard …. “cmon Sql!”
It was really useful, I’m just starting a new project that requires version control and I was just struggling last night between tower and beanstalk..push, commit..I was lost, thanks for making it so clear.
LOL, total car crash! was a good basic intro to Beanstalk though, thanks!
thanks Chris for doing this – I was also a bit apprehensive about getting this set up.
You had me laughing, especially when you’re talking to mySql, lol
for doing the search / replace thing when moving a site there are a couple of tools to make it easier:
a php script, I’ve used it many times
http://interconnectit.com/124/search-and-replace-for-wordpress-databases/
and a WordPress plugin
http://wordpress.org/extend/plugins/wp-migrate-db/
Yes! Thank you. I’m in the middle of watching the video and shouting “WP Migrate DB” at the screen. :-)
also check out the correct way to manage the wp-config file here:
http://markjaquith.wordpress.com/2011/06/24/wordpress-local-dev-tips/
I found this awesome Shell script by René Moser git-ftp with this script you can deploy your git-repo to ftp without using Beanstalk.
I use that for almost all my projects I’m not using beanstalk for. That’s a great FTP deployment script.
Please fix that typo or the kitten get’s it!
Hey Chris, if you are still having a problem with restarting your MySQL in MAMP, just open your terminal and type this:
killall -9 mysqld
It work`s for me ;-)
Goog job chris!
Awesome Chris, thanks!! I bypassed MAMP and set up my own stack on my Mac to get my local environment going, it was easier than I thought it would be…
Moved my current project into the repo and successfully deployed to my pre-production (staging) server. Tower is awesome, Beanstalk is awesome… signed up for the silver plan, you should get a commission! :)
One thing I started thinking; it’s probably best to only track your themes and custom plugins vs the entire WP core files. If you upgrade WP on your live or staging server via the admin panel it’s likely you’ll have a major mess on your hands the next time you deploy from Beanstalk.
First off, thank you for everything you do.
One quick question, say I make some changes to a simple page within a WordPress installation…maybe just updating some text. Will that update via the workflow you demonstrated? Or will I still need to do that updating on the live site?
I successfully got Tower, GitHub, Beanstalk rolling but it seems to be only committing changes in the actual file structure i.e. updating a plugin, etc.
This workflow only monitors the files you are tracking with Git. Changes made in WP are saved to your MySQL database. If you want your local dev copy to match your live site you’ll need to import your latest MySQL dump after making changes to the live site.
As an alternative to ignoring the file from the git repo, you could use different database credentials depending on the servers hostname.
With PHP it is done using the value of the _SERVER arrays SERVER_NAME key. An example:
if ($_SERVER['SERVER_NAME'] == ‘cc.local’) {
// if the hostname matches your local one use
// the local database connection info
} else {
// if its not, assume that we must be on the
// production site so use…
// the production database info
}
Hi Chris
I love your screencasts. I also like watching you make those little silly errors and then going back to correct them, it tells me its OK to make mistakes as we code and that’s as normal as it sounds it is :P
Its fun! I wanted to ask if you’ve ever considered enabling your iSight camera with a little picture playing in the bottom right corner as you speak. I think it would make it more personal but then I am sure you must have thought about this and there must be a very good reason not doing it.
Fill me up!
I hate when chrome doesn’t support local domains.
Erh. But there is a faster way of going around that.
Instead http://mydomain.whatup just
go
mydomain.whatup/
Chris,
When your MAMP kills your MySQL, you don’t actually have to reboot the whole system.
I wrote a tiny blog post on that here: http://www.themer.me/blog/misc/fix-mysql-mamp-pro-neverending-loading
And that helps even if you screw up your MAMP really bad like I did :) (this works even when “killall -9 mamp” doesn’t do the trick.
I’m using wamp server on win7
it works great and has a full simulation of PhpMyAdmin
i love it
Hi Chris
Why not use bitbucket.org? It’s free for up to 5 users and it has both Git and Mercurial.
I like your screencast, nice work.
What’s the best way to go about using beanstalk with site built off of EE? Make everything “Save Template as File”?
While Beanstalk is great for teams, if you just need version control for yourself, I use a post-commit-hook in Git in a way not too different from this: http://ryanflorence.com/deploying-websites-with-a-tiny-git-hook/
There are more elegant solution to what that articles suggests, but yes, if you have git installed on your server, you don’t need beanstalk. The problem is you don’t have git installed in almost all shared hosting and when you do client work, you either have to buy a beanstalk plan or go with git-ftp.
Always great to learn from here
Awesome stuff… you’ve inspired us and kept us smiling(again). Thanks Chris!
Our latest “how to” video to translate all of this for non-technical folks (BitNami cooperated!)
http://labzip.com/develop-wordpress-sites-locally-then-deploy-with-git-tower-beanstalk-thanks-chris-coyier-mark-jaquith/
Thanks for this screencast. I may still suck at git and I’m on windows. But I got a Free account on Beanstalk and after using it I was so amazed. I felt stupid for not using it with some of my own projects as I needed deployment and after going live, updating was such a pain in the ass. I kept breaking everything.
Now I just create a setup for Public Test Realm where people can test stuff and point out bugs. Once I’m happy I can manually Deploy the updated website to my Live server and be setup without problems.
Hola Cris, como va! Desde Argentina te escribo para saber que pasa con los screencast que no haces mas. Aprendo muchísimo y ya los vi a todos 100 veces y quisiera que hagas mas. Saludos.
It’s so funny watching you stumble through this :) I’m all like “Wait, wait, I know what’s wrong, and I know where that is!” watching that video :P
Great screencast though :) thanks!
That was groktastic
Confirmed/answered a ton of things i’ve had rattling around in there for ages .
Thanks a lot.
Great walkthrough! I am guessing if you decided you wanted to keep a full git repo like you did you would simply exclude the wp-config.php file from your commits?
I wouldn’t exclude
wp-config.php. There are some important things in there that you probably want to have in version control. Instead, do something like this to switch certain things around on the local environment vs production.Thanks, great tutorial.
After watching this tutorial I want out and upgraded my beanstalk account so I could make use of deployment, works great however i’m having trouble deploying to godaddy.com hosted website.
When trying to deploy i’m getting a “While trying to deploy revision 7977a… of your repository to the .com server an error occurred. Your FTP server is blocking connections from Beanstalk’s IP address: 69.20.73.216.” error.
I have contacted my host and they insure me they are not blocking this URL.
Anyone has success deploying to a godaddy.com shares hosting server?
Thanks again.
Chris, this video is awesome and the timing couldn’t have been better. I was just evaluating GitHub vs Beanstalkapp and checking out Tower as well. Keep up the good work!
Wow I wish I saw this video sooner. We started using Git also. We were befuddled about how to efficiently launch changes to the website. I’m going to suggest Beanstalk because right now, we’re doing manual backups and putting them on the production server.
Thanks Chris!
nice
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.