さて、Webアプリを作ってみたいぞということを思いついたわけです。
しかし色々難しそうだなあ…というところ調べていたらどうやらHerokuというのが簡単で良いらしい。
とりあえずHello Worldを出すところまででも頑張ってみようかと、チャレンジしてみました。
参考:Heroku初心者がHello, Herokuをしてみる - Qiita
↑基本これに沿ってやっています。@Arashiさんありがとう!
(因みにUbuntuは以前windowsでもLinuxコマンドを使いたいと思って入れたものでしたが、やはりlinuxコマンドを使った方法も試せて便利ですね)
ちなみに当方初心者ゆえ色々間違ってたらすみません。
Herokuと打つと何やっても謎のエラーを出される!?
heroku login
/mnt/c/Program Files/heroku/bin/../client/bin/heroku.cmd: 1: /mnt/c/Program Files/heroku/bin/../client/bin/heroku.cmd: @echo: not found
/mnt/c/Program Files/heroku/bin/../client/bin/heroku.cmd: 2: /mnt/c/Program Files/heroku/bin/../client/bin/heroku.cmd: setlocal: not found
/mnt/c/Program Files/heroku/bin/../client/bin/heroku.cmd: 4: /mnt/c/Program Files/heroku/bin/../client/bin/heroku.cmd: Syntax error: "(" unexpected (expecting "then")
→前に sudoを付ければ解決します。sudo heroku login、みたいに。つまり管理者権限が必要ということです。
git push heroku masterできない
git push heroku master
Username for 'https://git.heroku.com': ***
Password for 'https://***@git.heroku.com':
remote: ! WARNING:
remote: ! Do not authenticate with username and password using git.
remote: ! Run `heroku login` to update your credentials, then retry the git command.
remote: ! See documentation for details: https://devcenter.heroku.com/articles/git#http-git-authentication
fatal: Authentication failed for 'https://git.heroku.com/radiant-retreat-43439.git/'
何やら怒涛のエラー。よくわかりませんが、
git push heroku master がエラーを吐く - Qiita
によると
git config --global url.ssh://git@heroku.com/.insteadOf https://git.heroku.com/
と打てば解決するようです。
git config --global url.ssh://git@heroku.com/.insteadOf https://git.heroku.com/
git push heroku master
The authenticity of host 'heroku.com (50.19.85.156)' can't be established.
RSA key fingerprint is SHA256:8tF0wX2WquK45aGKs/Bh1dKmBXH08vxUe0VCJJWOA/o.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'heroku.com,50.19.85.156' (RSA) to the list of known hosts.
git@heroku.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
今度は違うエラー来た。何やらsshの鍵関係のエラーっぽいがよくわからない。そもそもWindowsってsshの鍵どこにあるんだ…?
虚ろな目でネットの海を彷徨っていたらまた導き手が現れてくださった。
Herokuで鍵がPermission denied (publickey). になる時 - opamp_sando's blog
heroku keys:addと打つと良いらしいので打ってみる。
sudo heroku keys:add
Found an SSH public key at /home/***/.ssh/id_rsa.pub
? Would you like to upload it to Heroku? Yes
Uploading /home/***/.ssh/id_rsa.pub SSH key... done
(なるほどここに.sshあったのか)
何やら上手く行ったらしい。よし今度こそ!
git push heroku master
Counting objects: 4, done.
~中略~
remote: Verifying deploy... done.
To ssh://heroku.com/radiant-retreat-43439.git
* [new branch] master -> master
おお~!
sudo heroku open
[sudo] password for ***:
▸ Error opening web browser.
▸ Error: Exited with code 3
▸
▸ Manually visit https://****.herokuapp.com/ in
▸ your browser.
何やら自動でブラウザを開けないから手動でアクセスしてみたら、しっかり
Hello, Heroku!!!
の文字が!!
スマホからアクセスしてもしっかり出ています。自分の文字が、webアプリの形で誰でも見れるように上がったんですね…!という感動。
さてこのままHelloで終わってしまうのか、何かしら使えるものをアップロードできるのか…頑張ってみます。