LoginSignup
2
1

More than 5 years have passed since last update.

AWS EC2 超速Webサーバ公開

Posted at

概要

WebhookやBot作りたいけど、WEBサーバ環境がない・・・時間もない
(準備が)超速Webサーバ公開にチャレンジ!
※手元にあるのはAWSアカウントのみ

前提

AWSアカウントがあり、コンソールへログイン可能なこと
何でも良いのでターミナルを用意していること

スタート

サービスから「EC2」でインスタンスの作成

Amazon Linux 無料利用枠の対象 t2.micro で作成
初めてならキーペア作成も忘れずに

セキュリティグループ

80ポートを許可する
タイプから「HTTP」を選べばok

パブリックDNSとキーでアクセス

ec2-user かつ作成された鍵でログイン

Python Web Framework Bottle インストール

Python Web Framework Bottle 超シンプルらしい
wget https://raw.githubusercontent.com/bottlepy/bottle/master/bottle.py

index.py 作成

注意host名をパブリックDNSに変える
vi index.py

index.py
from bottle import route, run, template

@route('/hello/<name>')
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)

run(host='パブリックDNS', port=80)

起動

sudo su -
cd /home/ec2-user
python index.py

超速完成

http://パブリックDNS/hello/world

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1