Contents
rootログイン
FTPでのファイル転送はrootで行う為に以下のサイトを参考
ソフトウェアのインストール
– Go to the server root directory with “cd /”
– yumでInstall required software with
“yum install python-virtualenv nginx gunicorn supervisor python-pip”
– apt-getでInstall required software with “
apt-get install python-virtualenv nginx gunicorn supervisor python-pip
ディレクトリの作成
– Create a new directory for the virtual environment with
“mkdir /opt/envs”
– Create a virtual environment with virtualenv
“virtualenv /opt/envs/virtual”
– Activate the virtual environment
“. /opt/envs/virtual/bin/activate”
– Install Python dependencies
“pip install bokeh”
“pip install flask”
“pip install gunicorn”
– Create a new directory inside the nginx server
“mkdir /var/log/nginx/flask”
– Create a new directory for uploading app files
“mkdir /opt/webapps” “mkdir /opt/webapps/bokehflask”
configuration filesの作成
– Make sure you have your configuration files ready
which are bokeh_serve.conf, flask.conf and default.
FTPアップロード
– Locate your local project directory on the left panel and select your
Python files and the templates directory or any other associated local directory,
but not configuration files
– Locate and select the server directory on the right panel and click Upload
/opt/webapps/bokehflaskにapp.pyとrandom_generator.pyをアップする
– Upload the file named “default” to
/etc/nginx/sites-available
using the same procedure
– Upload files
“bokeh_serve.conf”
and
“flask.conf”
to /etc/supervisor/conf.d using the same procedure
サーバー上での調整
– app.py を編集
以下のコマンドで開く
“nano /opt/webapps/bokehflask/app.py”
– インポート文を追加
“from werkzeug.contrib.fixers import ProxyFix”
to the remote app.py file.
– Modify the index function as follows:
1 2 3 4 5 |
def index(): url="http://104.236.40.212:5006" session=pull_session(url=url,app_path="/random_generator") bokeh_script=autoload_server(None,app_path="/random_generator",session_id=session.id, url=url) return render_template("index.html", bokeh_script=bokeh_script) |
– Add “app.wsgi_app = ProxyFix(app.wsgi_app)” to the remote app.py file after the index function.
– Save the file by pressing Control-X, then type y and then hit Enter.
– bokeh_serve.confを編集
以下のコマンドで開く
“nano /etc/supervisor/conf.d/bokeh_serve.conf”
and put your IP for –allow-websocket-origin and your IP and port 5006 for –host
実行
– Start the nginx webserver with
“service nginx restart”
– Start supervisor with
“service supervisor restart”
– Start flask with
“supervisorctl restart flask”
– Start bokeh server with
“supervisorctl restart bokeh_serve”
– Visit your app in the browswer at http://160.16.225.109 (put your own IP)
コメントを残す