본문 바로가기

삽질

Heroku 윈도우즈에서 사용하기

Heroku는 무료 Rails 호스팅 사이트 입니다. 다만 일반 호스팅과는 다르게 Git를 이용해서 Rails 어플리케이션을 갱신합니다. Heroku에 가입을 하고 로그인을 하면 http://heroku.com/pages/quickstart 화면이 나옵니다. 이제 자신이 만든 어플리케이션을 heroku에 등록해 봅시다. 

처음으로 Git 를 설치해야 합니다. 여기서는 msysgit를 설치 합니다. 홈페이지(http://code.google.com/p/msysgit/)에 가면 윈도우즈용 인스톨러가 있습니다. 설치합니다.

설치하는 중간에 Bash를 이용할 것인지 윈도우즈의 CMD를 이용할 것인지 묻는 창이 나옵니다. 저는 여기서 기본 윈도우즈의 CMD를 사용할 것이라서 두번째를 선택 했습니다. 

 SSH로 어떤것을 선택할지 묻는 옵션입니다. OpenSSH를 선택합니다.

Git 설치 후에 quickstart네 나온대로 실행하면 오류부터 발생합니다.

C:\myapp> heroku keys:add
No ssh public key found in C:\Users\Administrator/.ssh/id_[rd]sa.pub.  You may want to specify the full path to the keyfile.

일단 SSH 키를 생성해야 합니다. Git 설치시 후에 Git 시작메뉴아래에 잇는 Git Gui를 실행하고 Help 메뉴의 Show SSH Key 를 실행하면 아래 와 같은 화면이 나옵니다. 현재 키가 없다고 화면에 나옵니다. 옆의 Generate Key버튼을 누르면 키를 생성할 수 있습니다. 키 생성을 마친후 다시 명령을 내려 봅시다.

키에 한글 명이 있다면 한글을 영어로 바꾸어 줍니다. 생성된 Key의 끝에 유저명@컴퓨터 명이 붙습니다. 컴퓨터 명이 한글로 되어있으시면 파일 편집해서 영문으로 변경해 주세요.

한글로 되어있으면 Internal server error 라는 오류메세지가 표시됩니다.

C:\myapp>heroku keys:add
Uploading ssh public key C:\Users\Administrator/.ssh/id_rsa.pub
Enter your Heroku credentials.
Email: ggungs@gmail.com
Password:
Uploading ssh public key C:\Users\Administrator/.ssh/id_rsa.pub
    이 다음부터 QuickStart에 나온대로 진행하면 됩니다.
    C:\> cd myapp
    C:\myapp> git init
    C:\myapp> git add .
    C:\myapp> git commit -m "first commit"
    C:\myapp> heroku create --remote
    Created http://growing-water-46.heroku.com/ | git@heroku.com:growing-water-46.git
    Git remote heroku added
    
    C:\myapp>git push heroku master
    The authenticity of host 'heroku.com (75.101.145.87)' can't be established.
    RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'heroku.com,75.101.145.87' (RSA) to the list of known hosts.
    Enter passphrase for key '/c/Users/Administrator/.ssh/id_rsa': -> 키를 만들때 입력한 값을 넣습니다.
    Counting objects: 132, done.
    Compressing objects: 100% (118/118), done.
    Writing objects: 100% (132/132), 284.08 KiB | 45 KiB/s, done.
    Total 132 (delta 17), reused 0 (delta 0)
    -----> Heroku receiving push
    -----> Verifying repository integrity... done
    Compiled slug size is 0.2MBTo git@heroku.com:growing-water-46.git
    * [new branch] master > master-----> Launching......... done
    App deployed to Heroku
    
    C:\myapp>heroku rake db:migrate
    (in /mnt/home/slugs/4850_80a52d1_39b6/mnt)
    == CreateComments: migrating =================================================
    -- create_table(:comments)
     -> 0.0145s
    == CreateComments: migrated (0.0146s) ========================================
    C:\myapp>heroku open
    Opening http://growing-water-46.heroku.com/
    

    호스팅된 2차 도메인이름이 이해하기 어렵울 것입니다. 이럴땐 이름을 바꿀 수 있는 rename 명령어가 있습니다.

    C:\myapp>heroku rename testapp growing-water-46
    http://testapp.heroku.com/comments | git@heroku.com:testapp.git
    Git remote heroku updated
    

    호스팅된 Rails 어플리케이션 입니다. http://testapp.heroku.com/comments

    Heroku의 또다른 서비스인 http://herokugarden.com/ 을 이용하면 더 쉽게 레일즈 어플리케이션을 만들고 웹에서도 편집할 수 있다고 합니다.