5

I'm a beginner in DVCS (I'm from SVN world) and now that I mastered my own local repo, I would like to set up a remote computer (Amazon EC2) to hold my Web files so I can easily update the web application without FTP or some sorta things

I would like to end up using:

hg push http://hg.domain.com/webserver/hello

or git

git push myAmazon master

What do I have to configure in my remote server (installing Hg/Git) make a folder a repo using init and what should be next?


Maybe I wasn't 100% clear with the answer above, so here is a simple question

I want to replace FTP Upload by using Git / Hg push, how can I accomplish this?

So, let's imagine this scenario:

C:\Inetpub\wwwroot\mybrandNewWebApp is the root of a Site hosted in IIS (this is a remote computer, example: in Amazon EC2), at this directory I started up a repository using git init / hg init.

How can I configure this repository that from my own laptop I can do a push remote to "Uploading my changes"?

How can I configure this repository to be Reachable and Pushable?


Question from reading all comments?

Should I create other directory to be the repo and using upon a good push I could run a script that would actually update the website root directory?

balexandre
  • 73,608
  • 45
  • 233
  • 342
  • i.e. you want to use you VCS to deploy your web site – jk. Jun 30 '11 at 08:06
  • What kind of website technology are you using? Do you need to build the code, for instance? Do you have unit-tests? – Lasse V. Karlsen Jun 30 '11 at 08:38
  • @Lasse V. Karlsen **IIS** means Windows Server, I can easily run `build.exe` and run Unit tests from the command line, if I needed, I just don't get how to set everything up to my repo act as a remote one :/ – balexandre Jun 30 '11 at 10:19

3 Answers3

1

For Mercurial you'll need to set up hgweb the web server that Mercurial comes with, at least in the source-version.

The steps are (possibly incorrect order):

  1. Set up IIS on your server
  2. Download the Mercurial source, and follow a tutorial on which files to make available in the IIS application you set up
  3. Configure IIS to run python programs (Mercurial hgweb is a python cgi script)
  4. Configure hgweb for your hosting needs

There are numerous tutorials on the web, none of them 100% complete in the sense that if you follow them step by step it'll all work, but with a small amount of tinkering it will work.

Here's a couple:


Edit: My answer tells you how to set up a Mercurial web server that you can push to. Since your goal is to update the web server by pushing out your changes, there are other options:

I have the same type of setup, but what I have done is the following:

  1. I created an account online at one of the hosting companies (I use Kiln, but others will easily do)
  2. I then configured the repository I set up there to ping my web server whenever I pushed to the repository. Basically, when I push, the Kiln server will invoke a cgi-script on my own server with some information
  3. That cgi-script of mine that is pinged then executes a normal hg pull -u command in a local clone, and then a ROBOCOPY to mirror everything (except some debug files, and the .hg directory) into the main web site folder

This means that:

  1. I do not have to host my own repositories
  2. I do not need to go through the hassle of setting up my own Mercurial/Git server
  3. I do not need to handle (read: worry about) the security of that setup
  4. I still get push-to-update-website functionality
Community
  • 1
  • 1
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
  • Question: Does your steps are to install and run Mercurial as Web? All I wanted is to make a Public Website that I'm hosting in that Server a repository, so from my computer I can `push` my commits and update the web application... like FTP, but using Hg/Git. – balexandre Jun 30 '11 at 07:35
  • Yes, you need to install and run the Mercurial web server cgi application script to do this (for Mercurial.) I don't know what you would do for Git. – Lasse V. Karlsen Jun 30 '11 at 07:50
  • http://mercurial.selenic.com/wiki/hgserve says `Mercurial has a built-in light-weight web server which can be used for browsing a repository with a web browser or for allowing remote machines to pull from you.` - I'm not seeing anything regarding "allowing remote machines to push to you" .-/ I'm lost! – balexandre Jun 30 '11 at 07:52
  • That same server can be used to push, but that server is an ad-hoc server you only use ad-hoc. Mercurial has two servers. One is the hgweb python cgi script, with related files, and you need a normal web server (like Apache or IIS) to host that. The other is `hg serve` which spins up a web server in the repository you execute that command in, but it has security issues and isn't meant to be a permanent server. In any case, read my updated answer. – Lasse V. Karlsen Jun 30 '11 at 07:56
  • @balexandre: pushing over http(s) needs to be explicitly enabled, as it requires some kind of authentication scheme. – Macke Jun 30 '11 at 08:10
  • I use Kiln+FogBugz everyday, so I will take your approach, though it's not exactly what I would like to have, as your path, you always need a "middle men" (in this case Kiln). I was trying to set up my environment the way **Heroku** and **AppHarbor** do. – balexandre Jun 30 '11 at 11:11
1

If your run ssh on the server, you can use mercurial and git with their ssh-protocols.

You can even create repositories on the server that way:

 hg clone ~/myrepo ssh://user@server/hg/clone
Macke
  • 24,812
  • 7
  • 82
  • 118
  • that could be the path, I will read more about SSH protocols and see how can I enable that in my remote server. – balexandre Jun 30 '11 at 07:46
  • @balexandre: I've setup SSH (the server, sshd) on Windows machines with Cygwin previously, so that does work. However, I have no idea if it's suitable for Amazon EC2 Windows machines (which seems to be what you're targetting). That's a separate question though. ;) – Macke Jun 30 '11 at 08:09
0

You can use both Mercurial and Git for the purpose. If you push something from your computer, the tool will copy the new data to the remote server.

The problem is that the data just sits in the remote repository but you want it in a place where the Web server can see it, that is you're missing the "update" step (copy the data from repository into the Web server's file system).

To make it more clear:

  • commit moves the data from your local file system into your local repository.
  • push moves data between repositories (ignoring what's in the file system)
  • update/pull updates the file system. You have to do this on your web server.

My suggestion is to write a small script that runs hg update or git pull every hour or so. Install that script as a task in windows.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • I'm still doing the brainstorming first so I can check what steps to do in order to make my repository "Reachable and Pushable", but it's a good idea for when I'm at the implementation point. Thxs. – balexandre Jun 30 '11 at 07:47