Created
March 13, 2018 05:00
-
-
Save Ryusuke-Kawasaki/e13e0e4088f9832ff319f11f5f7ea2f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ ec2インスタンスを起動 | |
+ apacheの立ち上げ | |
yum install httpdの実行 | |
+ /var/www/以下の権限変更(以下を参考にする) | |
https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/install-LAMP.html | |
+ pythonとpipのインストール | |
sudo yum install python36-devel python36-libs python36-setuptools | |
sudo /usr/bin/easy_install-3.6 pip | |
+ wsgiをインストールするための必要なパッケージをインストール | |
sudo yum install httpd-devel | |
sudo yum install gcc | |
+ sudoの実行パスに/usr/local/binと/usr/local/sbinを追加 | |
sudo visudo | |
Defaults secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
+ mod_wsgiのインストール | |
sudo pip3 install mod_wsgi | |
+ flaskのインストール | |
sudo pip3 install flask | |
+ flaskのappファイルを作成 | |
cd /var/www/html/ | |
vi app.py | |
=============================== | |
# coding: utf-8 | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return "Hello, Flask!" | |
=============================== | |
if __name__ == "__main__": | |
app.run() | |
+ mod_wsgiとflaskを紐付けるwsgiファイルの作成 | |
vi adapter.wsgi | |
=============================== | |
# coding: utf-8 | |
import sys | |
sys.path.insert(0, '/var/www/html') | |
from app import app as application | |
=============================== | |
+ apacheの設定ファイルを作成 | |
sudo vi /etc/httpd/conf.d/flask.conf | |
=============================== | |
# /etc/httpd/modules には配置されないので指定が必要 | |
LoadModule wsgi_module /usr/local/lib64/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so | |
<VirtualHost *:80> | |
ServerName ec2-xxxxxxx.amazonaws.com:80 | |
DocumentRoot /var/www/html | |
WSGIScriptAlias / /var/www/html/adapter.wsgi | |
<Directory "/var/www/html/"> | |
options Indexes FollowSymLinks +ExecCGI | |
</Directory> | |
</VirtualHost> | |
=============================== | |
* 参考資料 | |
https://qiita.com/yabekenzo/items/346142e29db36b77e42d | |
https://www.xmisao.com/2013/10/11/sudoers-secure_path.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment