官术网_书友最值得收藏!

Installing the Heroku Toolbelt

Heroku applications are created and administered from the command line. To get started with Heroku, we need to install the Heroku Toolbelt. It contains everything we need to create and deploy new applications.

The toolbelt is an installer for three command-line tools:

  • Heroku Command Line Interface (CLI): This is an interface to the Heroku Platform API
  • Git: This is used for version control and to deploy our applications
  • Foreman: This is a tool to run Procfile-based applications

In this recipe, we will install the Heroku Toolbelt, making sure our machine is set up to use the Heroku CLI. We'll also be briefly introduced to the Heroku CLI. We'll learn about Git and Foreman later in the chapter.

Note

If you already have the Heroku Toolbelt, it might be beneficial to go through the following steps again to ensure that the latest version is installed.

Getting ready

First, we need to create a Heroku account with the following steps:

  1. Let's go to an account if we do not already have one.

    Note

    Remember to use a strong and unique password for Heroku. This account will be able to access our source code and data, so treat it like any other sensitive set of credentials.

  2. Next, let's install the Heroku Toolbelt. Specific download and installation instructions are available at https://toolbelt.heroku.com/ for Mac, Windows, and Linux.

    Note

    Throughout this book, we will be using a $ sign to indicate that a command should be run in a terminal. The $ sign is not part of the command.

  3. Once the Heroku Toolbelt is installed, we can verify that everything is working by opening up a terminal and running the following command:
    $ heroku --version
    heroku-toolbelt/3.11.1 (x86_64-darwin10.8.0) ruby/1.9.3
    

    We should see the version of the Heroku Toolbelt we are using printed to the console.

How to do it...

Now that we have the Heroku Toolbelt installed, let's log in to our account via the CLI and authorize our computer by uploading our public key using the following steps:

  1. Let's log in by opening up a terminal and running the following command:
    $ heroku login
    Username: youremail@example.com
    Password (typing will be hidden):
    Could not find an existing public key.Would you like to generate one? [Yn]Generating new SSH public key.Uploading ssh public key /Users/mc/.ssh/id_rsa.pub
    

    If we do not have an existing public key, the Heroku CLI will provide us with instructions on how to create one here. This key will be uploaded to Heroku's servers and used for authentication whenever we push new code to our applications.

    Note

    We'll need to repeat this step for any other computers we use Heroku from.

  2. We can ensure that we are authenticated with the auth:whoami command. If logged in successfully, it will print our e-mail address:
    $ heroku auth:whoami
    youremail@example.com
    
  3. Finally, we should go to the Heroku dashboard and verify our account by adding a credit card. Having a verified account will allow us to scale our applications and install add-ons (https://dashboard.heroku.com/account).

How it works…

The Heroku Toolbelt installs all the necessary tools to create and administer our Heroku applications. It's essential for us to become comfortable with Heroku's command-line tools. Even though many tasks can be completed on Heroku's website, not everything is available through the dashboard. For full control over our applications, we have to use the CLI.

Authentication

Ever wondered how Heroku keeps us logged in to the CLI? During the login process, Heroku stores an API key for our account in our .netrc file. The .netrc file is a dotfile that lives in our home directory. It's a common file that applications use to store credentials to log in to remote hosts. The API key stored in this file is used for subsequent logins and keeps us logged in to our Heroku account. If we open our .netrc file, we'll see an entry for deletes the entry from our .netrc file, thus logging us out.

Note

We do not need to worry about updating Heroku Toolbelt; it will automatically check for updates for us.

See also

主站蜘蛛池模板: 福州市| 宁津县| 廉江市| 华安县| 桐梓县| 合肥市| 定襄县| 罗定市| 龙泉市| 蓬溪县| 琼结县| 肇东市| 迭部县| 来安县| 裕民县| 大丰市| 南郑县| 望都县| 安乡县| 金堂县| 波密县| 赣榆县| 邯郸县| 玉屏| 梁山县| 吉首市| 江油市| 潮安县| 普宁市| 蕉岭县| 弥勒县| 昌乐县| 繁峙县| 壶关县| 车致| 八宿县| 屏南县| 谢通门县| 巴中市| 滕州市| 历史|