差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 次のリビジョン両方とも次のリビジョン | ||
python:uwsgi [2020/04/08 09:38] – ともやん | python:uwsgi [2020/04/25 15:42] – ともやん | ||
---|---|---|---|
行 11: | 行 11: | ||
overflow-x: hidden; | overflow-x: hidden; | ||
font-size: 10px; | font-size: 10px; | ||
+ | } | ||
+ | #logo { | ||
+ | background-color: | ||
+ | padding: 10px; | ||
+ | width: fit-content; | ||
+ | } | ||
+ | #logo p { | ||
+ | margin: 0; | ||
} | } | ||
</ | </ | ||
</ | </ | ||
====== uWSGI - WSGI アプリケーションコンテナ ====== | ====== uWSGI - WSGI アプリケーションコンテナ ====== | ||
+ | <WRAP #logo> | ||
{{: | {{: | ||
+ | </ | ||
\\ | \\ | ||
**uWSGI** は、「ホスティングサービスを構築するためのフルスタックの開発を的とする」ソフトウェアアプリケーションです。プロジェクトでサポートされている最初のプラグインである [[https:// | **uWSGI** は、「ホスティングサービスを構築するためのフルスタックの開発を的とする」ソフトウェアアプリケーションです。プロジェクトでサポートされている最初のプラグインである [[https:// | ||
\\ | \\ | ||
uWSGIは、Cherokee や Nginx などの Web サーバーと組み合わせて Python Web アプリケーションを提供するためによく使用され、uWSGI のネイティブ uwsgi プロトコルを直接サポートする。\\ | uWSGIは、Cherokee や Nginx などの Web サーバーと組み合わせて Python Web アプリケーションを提供するためによく使用され、uWSGI のネイティブ uwsgi プロトコルを直接サポートする。\\ | ||
- | [[wpjp> | + | [[wp> |
\\ | \\ | ||
本家: [[https:// | 本家: [[https:// | ||
行 27: | 行 37: | ||
===== dnf によるインストール ===== | ===== dnf によるインストール ===== | ||
< | < | ||
- | $ sudo dnf install uwsgi | + | $ sudo dnf install uwsgi uwsgi-plugin-python3 |
</ | </ | ||
<WRAP prewrap 100% # | <WRAP prewrap 100% # | ||
< | < | ||
- | メタデータの期限切れの最終確認: | + | メタデータの期限切れの最終確認: |
依存関係が解決しました。 | 依存関係が解決しました。 | ||
- | ================================================================================== | + | ========================================================================================== |
- | | + | |
- | ================================================================================== | + | ========================================================================================== |
インストール: | インストール: | ||
- | | + | |
+ | | ||
+ | 依存関係のインストール: | ||
+ | | ||
トランザクションの概要 | トランザクションの概要 | ||
- | ================================================================================== | + | ========================================================================================== |
- | インストール | + | インストール |
- | ダウンロードサイズの合計: 383 k | + | 合計サイズ: |
- | インストール済みのサイズ: | + | インストール済みのサイズ: |
これでよろしいですか? | これでよろしいですか? | ||
パッケージのダウンロード: | パッケージのダウンロード: | ||
- | uwsgi-2.0.18-2.fc31.x86_64.rpm | + | [SKIPPED] |
- | ---------------------------------------------------------------------------------- | + | [SKIPPED] uwsgi-plugin-common-2.0.18-2.fc31.x86_64.rpm: |
- | 合計 | + | [SKIPPED] uwsgi-plugin-python3-2.0.18-2.fc31.x86_64.rpm: |
+ | ------------------------------------------------------------------------------------------ | ||
+ | 合計 | ||
トランザクションの確認を実行中 | トランザクションの確認を実行中 | ||
トランザクションの確認に成功しました。 | トランザクションの確認に成功しました。 | ||
行 55: | 行 70: | ||
トランザクションのテストに成功しました。 | トランザクションのテストに成功しました。 | ||
トランザクションを実行中 | トランザクションを実行中 | ||
- | 準備 | + | 準備 |
- | scriptletの実行中: | + | scriptletの実行中: |
- | インストール中 | + | インストール中 |
- | scriptletの実行中: | + | scriptletの実行中: |
Executing systemd post-install tasks | Executing systemd post-install tasks | ||
- | 検証 | + | |
+ | インストール中 | ||
+ | scriptletの実行中: | ||
+ | | ||
+ | 検証 | ||
+ | 検証 | ||
インストール済み: | インストール済み: | ||
- | uwsgi-2.0.18-2.fc31.x86_64 | + | uwsgi-2.0.18-2.fc31.x86_64 |
+ | uwsgi-plugin-python3-2.0.18-2.fc31.x86_64 | ||
完了しました! | 完了しました! | ||
</ | </ | ||
</ | </ | ||
+ | |||
+ | ==== uWSGI Emperor Service の有効化 ==== | ||
+ | < | ||
+ | $ sudo systemctl enable uwsgi | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | Created symlink / | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== uwsgi 動作確認 ==== | ||
+ | Python バージョン確認\\ | ||
+ | < | ||
+ | $ python -VV | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | Python 3.7.6 (default, Jan 30 2020, 09:44:41) | ||
+ | [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Python 仮想環境の作成\\ | ||
+ | < | ||
+ | $ python -m venv py3dj3_venv | ||
+ | </ | ||
+ | |||
+ | Python 仮想環境の有効化\\ | ||
+ | < | ||
+ | $ . py3dj3_venv/ | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | (py3dj3_venv) $ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Python 仮想環境の pip を更新\\ | ||
+ | < | ||
+ | (py3dj3_venv) $ python -m pip install --upgrade pip | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | Collecting pip | ||
+ | Using cached https:// | ||
+ | Installing collected packages: pip | ||
+ | Found existing installation: | ||
+ | Uninstalling pip-19.1.1: | ||
+ | Successfully uninstalled pip-19.1.1 | ||
+ | Successfully installed pip-20.0.2 | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Django のインストール\\ | ||
+ | < | ||
+ | (py3dj3_venv) $ pip install django | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | Collecting django | ||
+ | Using cached Django-3.0.5-py3-none-any.whl (7.5 MB) | ||
+ | Collecting sqlparse> | ||
+ | Using cached sqlparse-0.3.1-py2.py3-none-any.whl (40 kB) | ||
+ | Collecting pytz | ||
+ | Using cached pytz-2019.3-py2.py3-none-any.whl (509 kB) | ||
+ | Collecting asgiref~=3.2 | ||
+ | Using cached asgiref-3.2.7-py2.py3-none-any.whl (19 kB) | ||
+ | Installing collected packages: sqlparse, pytz, asgiref, django | ||
+ | Successfully installed asgiref-3.2.7 django-3.0.5 pytz-2019.3 sqlparse-0.3.1 | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Django プロジェクトの作成\\ | ||
+ | < | ||
+ | (py3dj3_venv) $ django-admin startproject django_project | ||
+ | </ | ||
+ | |||
+ | Python 仮想環境の終了\\ | ||
+ | < | ||
+ | (py3dj3_venv) $ deactivate | ||
+ | </ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | $ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | 一番シンプルな uwsgi コマンドで Django アプリの動作確認を行う\\ | ||
+ | <WRAP prewrap 100%> | ||
+ | < | ||
+ | $ uwsgi --http-socket :8000 --plugin python3 --virtualenv / | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP prewrap 100% # | ||
+ | < | ||
+ | *** Starting uWSGI 2.0.18 (64bit) on [Tue Apr 14 03:23:45 2020] *** | ||
+ | compiled with version: 9.1.1 20190605 (Red Hat 9.1.1-2) on 27 July 2019 00:00:00 | ||
+ | os: Linux-4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 | ||
+ | nodename: Cmon | ||
+ | machine: x86_64 | ||
+ | clock source: unix | ||
+ | pcre jit disabled | ||
+ | detected number of CPU cores: 4 | ||
+ | current working directory: / | ||
+ | detected binary path: / | ||
+ | chdir() to / | ||
+ | *** WARNING: you are running uWSGI without its master process manager *** | ||
+ | your processes number limit is 50741 | ||
+ | your memory page size is 4096 bytes | ||
+ | detected max file descriptor number: 1048576 | ||
+ | lock engine: pthread robust mutexes | ||
+ | thunder lock: disabled (you can enable it with --thunder-lock) | ||
+ | uwsgi socket 0 bound to TCP address :8000 fd 3 | ||
+ | Python version: 3.7.6 (default, Jan 30 2020, 09: | ||
+ | PEP 405 virtualenv detected: / | ||
+ | Set PythonHome to / | ||
+ | *** Python threads support is disabled. You can enable it with --enable-threads *** | ||
+ | Python main interpreter initialized at 0x98b450 | ||
+ | your server socket listen backlog is limited to 100 connections | ||
+ | your mercy for graceful operations on workers is 60 seconds | ||
+ | mapped 72920 bytes (71 KB) for 1 cores | ||
+ | *** Operational MODE: single process *** | ||
+ | WSGI app 0 (mountpoint='' | ||
+ | *** uWSGI is running in multiple interpreter mode *** | ||
+ | spawned uWSGI worker 1 (and the only) (pid: 5711, cores: 1) | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | [[http:// | ||
+ | {{: | ||
+ | |||
+ | uwsgi コマンドを **Ctrl + C** で終了\\ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | < | ||
+ | [pid: 5711|app: 0|req: 1/1] 127.0.0.1 () {42 vars in 890 bytes} [Mon Apr 13 18:24:59 2020] GET / => generated 16351 bytes in 21 msecs (HTTP/1.1 200) 4 headers in 123 bytes (1 switches on core 0) | ||
+ | Not Found: / | ||
+ | [pid: 5711|app: 0|req: 2/2] 127.0.0.1 () {40 vars in 805 bytes} [Mon Apr 13 18:24:59 2020] GET / | ||
+ | [pid: 5711|app: 0|req: 3/3] 127.0.0.1 () {42 vars in 884 bytes} [Mon Apr 13 18:27:42 2020] GET / => generated 16351 bytes in 14 msecs (HTTP/1.1 200) 4 headers in 123 bytes (1 switches on core 0) | ||
+ | Not Found: / | ||
+ | [pid: 5711|app: 0|req: 4/4] 127.0.0.1 () {40 vars in 805 bytes} [Mon Apr 13 18:27:42 2020] GET / | ||
+ | Ctrl + C を入力 | ||
+ | $ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== uWSGI Emperor Service の ini ファイルを設定 ===== | ||
+ | Django アプリのミニマム設定\\ | ||
+ | <code ini / | ||
+ | http-socket = :8000 | ||
+ | plugin = python3 | ||
+ | virtualenv = / | ||
+ | chdir = / | ||
+ | wsgi-file = django_project/ | ||
+ | </ | ||
+ | uWSGI Emperor Service の開始 | ||
+ | < | ||
+ | $ sudo systemctl start uwsgi | ||
+ | </ | ||
+ | uWSGI Emperor Service リッスン確認\\ | ||
+ | < | ||
+ | $ sudo netstat -anp4 | grep uwsgi | ||
+ | tcp 0 0 0.0.0.0: | ||
+ | </ | ||
===== pip によるインストール ===== | ===== pip によるインストール ===== | ||
行 186: | 行 371: | ||
[[https:// | [[https:// | ||
[[https:// | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||