差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
python:uwsgi [2020/04/08 09:38] – ともやん | python:uwsgi [2020/09/11 16:50] (現在) – ともやん | ||
---|---|---|---|
行 1: | 行 1: | ||
- | < | ||
- | < | ||
- | #result pre, #mincode pre { | ||
- | overflow: scroll; | ||
- | overflow-x: hidden; | ||
- | font-size: 10px; | ||
- | } | ||
- | # | ||
- | height: 400px; | ||
- | overflow: scroll; | ||
- | overflow-x: hidden; | ||
- | font-size: 10px; | ||
- | } | ||
- | </ | ||
- | </ | ||
====== 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: | 行 14: | ||
===== 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: | 行 47: | ||
トランザクションのテストに成功しました。 | トランザクションのテストに成功しました。 | ||
トランザクションを実行中 | トランザクションを実行中 | ||
- | 準備 | + | 準備 |
- | 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 によるインストール ===== | ||
行 181: | 行 343: | ||
Include conf.modules.d/ | Include conf.modules.d/ | ||
</ | </ | ||
+ | </ | ||
+ | |||
+ | ===== uWSGI 関連パッケージ ===== | ||
+ | <WRAP prewrap 100%> | ||
+ | <code powershell> | ||
+ | $ dnf search uwsgi | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP prewrap 100% # | ||
+ | <code powershell> | ||
+ | メタデータの期限切れの最終確認: | ||
+ | ================================= Name 完全一致: | ||
+ | uwsgi.x86_64 : Fast, self-healing, | ||
+ | ============================== Name & Summary 一致: uwsgi =============================== | ||
+ | uwsgi-docs.x86_64 : uWSGI - Documentation | ||
+ | uwsgi-alarm-curl.x86_64 : uWSGI - Curl alarm plugin | ||
+ | uwsgi-alarm-xmpp.x86_64 : uWSGI - Curl alarm plugin | ||
+ | uwsgi-plugin-rack.x86_64 : uWSGI - Ruby rack plugin | ||
+ | uwsgi-plugin-sqlite3.x86_64 : uWSGI - SQLite3 plugin | ||
+ | uwsgi-logger-file.x86_64 : uWSGI - logfile logger plugin | ||
+ | uwsgi-logger-pipe.x86_64 : uWSGI - logpipe logger plugin | ||
+ | uwsgi-plugin-lua.x86_64 : uWSGI - Plugin for LUA support | ||
+ | uwsgi-plugin-pam.x86_64 : uWSGI - Plugin for PAM support | ||
+ | uwsgi-plugin-php.x86_64 : uWSGI - Plugin for PHP support | ||
+ | uwsgi-plugin-pty.x86_64 : uWSGI - Plugin for PTY support | ||
+ | uwsgi-plugin-rpc.x86_64 : uWSGI - Plugin for RPC support | ||
+ | uwsgi-logger-syslog.x86_64 : uWSGI - syslog logger plugin | ||
+ | uwsgi-logger-zeromq.x86_64 : uWSGI - ZeroMQ logger plugin | ||
+ | uwsgi-logger-redis.x86_64 : uWSGI - redislog logger plugin | ||
+ | uwsgi-plugin-ldap.x86_64 : uWSGI - Plugin for LDAP support | ||
+ | uwsgi-plugin-psgi.x86_64 : uWSGI - Plugin for PSGI support | ||
+ | uwsgi-plugin-ruby.x86_64 : uWSGI - Plugin for Ruby support | ||
+ | uwsgi-logger-rsyslog.x86_64 : uWSGI - rsyslog logger plugin | ||
+ | uwsgi-logger-crypto.x86_64 : uWSGI - logcrypto logger plugin | ||
+ | uwsgi-logger-socket.x86_64 : uWSGI - logsocket logger plugin | ||
+ | uwsgi-plugin-cache.x86_64 : uWSGI - Plugin for cache support | ||
+ | uwsgi-plugin-dummy.x86_64 : uWSGI - Plugin for Dummy support | ||
+ | uwsgi-plugin-geoip.x86_64 : uWSGI - Plugin for GeoIP support | ||
+ | uwsgi-logger-graylog2.x86_64 : uWSGI - Graylog2 logger plugin | ||
+ | uwsgi-plugin-common.x86_64 : uWSGI - Common plugins for uWSGI | ||
+ | uwsgi-plugin-gccgo.x86_64 : uWSGI - Plugin for GoLang support | ||
+ | uwsgi-plugin-ssi.x86_64 : uWSGI - Server Side Includes plugin | ||
+ | uwsgi-plugin-cplusplus.x86_64 : uWSGI - Plugin for C++ support | ||
+ | uwsgi-plugin-nagios.x86_64 : uWSGI - Plugin for Nagios support | ||
+ | uwsgi-plugin-ugreen.x86_64 : uWSGI - Plugin for uGreen support | ||
+ | uwsgi-plugin-webdav.x86_64 : uWSGI - Plugin for WebDAV support | ||
+ | uwsgi-router-raw.x86_64 : uWSGI - Plugin for Raw Router support | ||
+ | uwsgi-router-ssl.x86_64 : uWSGI - Plugin for SSL router support | ||
+ | uwsgi-plugin-rrdtool.x86_64 : uWSGI - Plugin for RRDTool support | ||
+ | uwsgi-router-fast.x86_64 : uWSGI - Plugin for FastRouter support | ||
+ | uwsgi-plugin-coroae.x86_64 : uWSGI - Plugin for PERL Coro support | ||
+ | uwsgi-plugin-fiber.x86_64 : uWSGI - Plugin for Ruby Fiber support | ||
+ | uwsgi-plugin-mono.x86_64 : uWSGI - Plugin for Mono / .NET support | ||
+ | uwsgi-router-hash.x86_64 : uWSGI - Plugin for Hash router support | ||
+ | uwsgi-router-http.x86_64 : uWSGI - Plugin for HTTP router support | ||
+ | uwsgi-plugin-airbrake.x86_64 : uWSGI - Plugin for AirBrake support | ||
+ | uwsgi-plugin-mongrel2.x86_64 : uWSGI - Plugin for Mongrel2 support | ||
+ | uwsgi-plugin-notfound.x86_64 : uWSGI - Plugin for notfound support | ||
+ | uwsgi-plugin-zergpool.x86_64 : uWSGI - Plugin for zergpool support | ||
+ | uwsgi-devel.i686 : uWSGI - Development header files and libraries | ||
+ | uwsgi-devel.x86_64 : uWSGI - Development header files and libraries | ||
+ | uwsgi-logger-systemd.x86_64 : uWSGI - systemd journal logger plugin | ||
+ | uwsgi-plugin-dumbloop.x86_64 : uWSGI - Plugin for Dumb Loop support | ||
+ | uwsgi-plugin-python3.x86_64 : uWSGI - Plugin for Python 3.7 support | ||
+ | uwsgi-router-cache.x86_64 : uWSGI - Plugin for Cache router support | ||
+ | uwsgi-router-redis.x86_64 : uWSGI - Plugin for Redis router support | ||
+ | uwsgi-router-uwsgi.x86_64 : uWSGI - Plugin for uWSGI router support | ||
+ | uwsgi-plugin-curl-cron.x86_64 : uWSGI - Plugin for CURL Cron support | ||
+ | uwsgi-plugin-glusterfs.x86_64 : uWSGI - Plugin for GlusterFS support | ||
+ | uwsgi-stats-pusher-file.x86_64 : uWSGI - File Stats Pusher for uWSGI | ||
+ | uwsgi-log-encoder-msgpack.x86_64 : uWSGI - msgpack log encoder plugin | ||
+ | uwsgi-router-radius.x86_64 : uWSGI - Plugin for Radius router support | ||
+ | uwsgi-router-spnego.x86_64 : uWSGI - Plugin for SPNEgo router support | ||
+ | uwsgi-router-static.i686 : uWSGI - Plugin for Static router support | ||
+ | uwsgi-router-static.x86_64 : uWSGI - Plugin for Static router support | ||
+ | uwsgi-router-xmldir.x86_64 : uWSGI - Plugin for XMLDir router rupport | ||
+ | uwsgi-transformation-gzip.x86_64 : uWSGI - GZip Transformation plugin | ||
+ | uwsgi-router-tuntap.x86_64 : uWSGI - Plugin for TUN/TAP router support | ||
+ | uwsgi-plugin-carbon.x86_64 : uWSGI - Plugin for Carbon/ | ||
+ | uwsgi-plugin-xattr.x86_64 : uWSGI - Plugin for Extra Attributes support | ||
+ | uwsgi-router-expires.x86_64 : uWSGI - Plugin for Expires router support | ||
+ | uwsgi-router-forkpty.x86_64 : uWSGI - Plugin for ForkPTY router support | ||
+ | uwsgi-router-metrics.x86_64 : uWSGI - Plugin for Metrics router support | ||
+ | uwsgi-router-rewrite.x86_64 : uWSGI - Plugin for Rewrite router support | ||
+ | uwsgi-plugin-spooler.x86_64 : uWSGI - Plugin for Remote Spooling support | ||
+ | uwsgi-stats-pusher-socket.x86_64 : uWSGI - Socket Stats Pusher for uWSGI | ||
+ | uwsgi-stats-pusher-statsd.x86_64 : uWSGI - StatsD Stats Pusher for uWSGI | ||
+ | uwsgi-stats-pusher-zabbix.x86_64 : uWSGI - Zabbix Stats Pusher for uWSGI | ||
+ | uwsgi-plugin-xslt.x86_64 : uWSGI - Plugin for XSLT transformation support | ||
+ | uwsgi-router-redirect.x86_64 : uWSGI - Plugin for Redirect router support | ||
+ | uwsgi-transformation-tofile.x86_64 : uWSGI - ToFile Transformation plugin | ||
+ | uwsgi-plugin-rbthreads.x86_64 : uWSGI - Ruby native threads support plugin | ||
+ | uwsgi-router-memcached.x86_64 : uWSGI - Plugin for Memcached router support | ||
+ | uwsgi-transformation-chunked.x86_64 : uWSGI - Chunked Transformation plugin | ||
+ | uwsgi-transformation-toupper.x86_64 : uWSGI - ToUpper Transformation plugin | ||
+ | uwsgi-router-basicauth.x86_64 : uWSGI - Plugin for Basic Auth router support | ||
+ | uwsgi-transformation-offload.x86_64 : uWSGI - Off-Load Transformation plugin | ||
+ | uwsgi-transformation-template.x86_64 : uWSGI - Template Transformation plugin | ||
+ | uwsgi-plugin-cheaper-busyness.x86_64 : uWSGI - Plugin for Cheaper Busyness algos | ||
+ | uwsgi-plugin-python3-gevent.x86_64 : uWSGI - Plugin for Python 3.7 GEvent support | ||
+ | uwsgi-plugin-python3-greenlet.x86_64 : uWSGI - Plugin for Python 3.7 Greenlet support | ||
+ | uwsgi-plugin-python3-tornado.x86_64 : uWSGI - Plugin for Tornado (Python 3.7) support | ||
+ | python3-uwsgidecorators.x86_64 : Python 3.7 decorators providing access to the uwsgi API | ||
+ | </ | ||
</ | </ | ||
行 186: | 行 452: | ||
[[https:// | [[https:// | ||
[[https:// | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||