「UWSGI」の版間の差分
Kusakata.bot2 (トーク | 投稿記録) Pkg/AUR テンプレートの更新 |
トラブルシューティングを翻訳して追加 |
||
| 91行目: | 91行目: | ||
uwsgi_pass 127.0.0.1:3031; |
uwsgi_pass 127.0.0.1:3031; |
||
} |
} |
||
== トラブルシューティング == |
|||
=== Apache httpd === |
|||
==== AH00957: uwsgi: attempt to connect to 127.0.0.1:0 (*) failed ==== |
|||
デフォルトの uWSGI ポート (3031) は、(現時点では?) Apache httpd サーバーでは機能しません。詳細については、[https://github.com/unbit/uwsgi/issues/1491] を参照してください。 |
|||
== 参照 == |
== 参照 == |
||
2023年10月28日 (土) 14:05時点における版
uWSGI は高速で自己回復機能のある、開発者とシステム管理人に優しいアプリケーションコンテナサーバーです。C だけで書かれています。
インストール
公式リポジトリの uwsgi パッケージをインストールしてください。パッケージをコンパクトにするために、プラグインは付属していません。外部プラグインは別にインストールする必要があります。C で書かれているためとても効率的なソフトウェアです。gunicorn など Python で書かれた代替も存在しますが、どうしても動作は遅くなってしまいます。
サービスの起動
/etc/uwsgi/ の中に同一の名前の設定ファイルを作成してください。以下では /etc/uwsgi/helloworld.ini を使っています。スタートアップ時にデフォルトで uwsgi サービスを有効にするには、次を実行:
# systemctl enable uwsgi@helloworld
これで /etc/uwsgi/helloworld.ini 設定されたアプリケーションのサービスが有効になります。また、以下のコマンドを使ってソケットインターフェイスで有効にすることも可能です:
# systemctl enable uwsgi@helloworld.socket
もしくは、Emperor モード サービスを実行することができます。このモードを使うと uwsgi インスタンスで (emperor と呼ばれる) メインスーパーバイザーを使って様々なアプリ (vassal と呼ばれます) が動くようになります。有効にするには、次を入力:
# systemctl enable emperor.uwsgi
ソケットを使うこともできます:
# systemctl enable emperor.uwsgi.socket
Emperor の設定は /etc/uwsgi/emperor.ini にあります。
設定
/etc/uwsgi/archlinux.ini は付属していません。/etc/uwsgi/ 内のファイルを編集することで設定ができます。パッケージに含まれているビルドファイルは /etc/uwsgi/archlinux.ini に存在します。
詳しくは uwsgi のドキュメント を見て下さい。
アプリケーションの設定
以下は python をサポートするシンプルな例です。pacman で community リポジトリから uwsgi-plugin-python または uwsgi-plugin-python2[リンク切れ: パッケージが存在しません] プラグインをインストールする必要があります。
[uwsgi] chdir = /srv/http/helloworld module = helloworld plugins = python
以下のような構文を使うことで uwsgi を別個に実行することも可能です:
--wsgi-file オプションを使うことはできません。公式ガイドではソースからビルドすることを推奨しています (http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html#installing-uwsgi-with-python-support を参照)。uwsgi --socket 127.0.0.1:3031 --plugin python2 --wsgi-file ~/foo.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191 --uid --gid
上記のコマンドを root で実行するのは止めてください。
Php アプリケーション
uwsgi の php プラグインをインストール: uwsgi-plugin-php
/etc/uwsgi/mysite.ini
[uwsgi] ; maximum number of worker processes processes = 4 ; the user and group id of the process once it’s started uid = http gid = http socket = /run/uwsgi/%n.sock master = true chdir = /srv/http/%n ; php plugins = php ; jail our php environment php-docroot = /srv/http/%n php-index = index.php ; clear environment on exit vacuum = true
Nginx 設定:
location = /index.php {
include uwsgi_params;
uwsgi_modifier1 14;
uwsgi_pass unix:/run/uwsgi/mysite.sock;
}
Nginx の設定
location / {
root /usr/share/nginx/html;
index index.html index.htm;
include uwsgi_params;
# uwsgi_pass unix:/var/run/uwsgi/helloworld.sock;
uwsgi_pass 127.0.0.1:3031;
}
トラブルシューティング
Apache httpd
AH00957: uwsgi: attempt to connect to 127.0.0.1:0 (*) failed
デフォルトの uWSGI ポート (3031) は、(現時点では?) Apache httpd サーバーでは機能しません。詳細については、[1] を参照してください。