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

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

主站蜘蛛池模板: 荔浦县| 襄垣县| 满洲里市| 江源县| 柞水县| 西盟| 郎溪县| 开封县| 阜康市| 桦南县| 蓬莱市| 和田县| 靖江市| 陆河县| 龙里县| 乌鲁木齐市| 东兰县| 贡嘎县| 财经| 巩留县| 潞西市| 吉木萨尔县| 太仆寺旗| 营口市| 漾濞| 海原县| 张家口市| 洪洞县| 吉安市| 林西县| 斗六市| 织金县| 神农架林区| 溆浦县| 紫云| 铜梁县| 微山县| 黄大仙区| 青川县| 巴里| 吴忠市|