[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
ただいまコメントを受けつけておりません。
前に Apache2 からアクセスするようにゆとシート2 for SW2.5 を動かしたので、nginx 経由でなんとかする。
いろいろあって nginx 経由で cgi したくなったので実験台に過去に動かした実績があるゆとシート2が選ばれたのである。前に紹介した時に比較してさらに強力な機能がゆとシート2 for SW2.5 には増えているので各位も触ってみてほしい。
この記事自身は FCGI Wrapの公式ページを参考にセットアップしました。
と言っているので FCGI Wrap | NGINX を読んだ方が良かったか、と今更後悔している。
Ubuntu 16.04.6 を使っている。
nginx 1.10.3 を使っている。
sudo apt install fcgiwrap する。
なんか、以下のような便利なやつがあるので流用する。
$ cat /usr/share/doc/fcgiwrap/examples/nginx.conf
# Include this file on your nginx.conf to support debian cgi-bin scripts using
# fcgiwrap
location ~ \.cgi$ {
# Disable gzip (it makes scripts feel slower since they have to complete
# before getting gzipped)
gzip off;
# Set the root to /usr/lib (inside this location this means that we are
# giving access to the files under /usr/lib/cgi-bin)
root /usr/lib;
# Fastcgi socket
fastcgi_pass unix:/var/run/fcgiwrap.socket;
# Fastcgi parameters, include the standard ones
include /etc/nginx/fastcgi_params;
# Adjust non standard parameters (SCRIPT_FILENAME)
fastcgi_param SCRIPT_FILENAME /usr/lib$fastcgi_script_name;
}
$ cd /etc/nginx # もともとあったファイルを退避 /etc/nginx$ sudo mv fastcgi.conf fastcgi.conf_bk # 上述のファイルを複製 /etc/nginx$ sudo cp /usr/share/doc/fcgiwrap/examples/nginx.conf ./fastcgi.conf
適当なエディタで以下のようにいじる。太字部分がいじった部分。
/etc/nginx$ cat fastcgi.conf
# Include this file on your nginx.conf to support debian cgi-bin scripts using
# fcgiwrap
# なお、ここを /ytsheet とかにしてしまうと css とかが読めなくなる
# 拡張子が .cgi じゃないのであればまた設定は考えないといけない。
# TRPG 系なら .rb とか多いのでは?
location ~ \.cgi$ {
# Disable gzip (it makes scripts feel slower since they have to complete
# before getting gzipped)
gzip off;
# Set the root to /usr/lib (inside this location this means that we are
# giving access to the files under /usr/lib/cgi-bin)
# root /usr/lib;
# Fastcgi socket
fastcgi_pass unix:/var/run/fcgiwrap.socket;
# Fastcgi parameters, include the standard ones
include /etc/nginx/fastcgi_params;
# Adjust non standard parameters (SCRIPT_FILENAME)
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
返す刃で nginx の config ファイルをいじる。太字部分がいじった部分。
server {
include /etc/nginx/fastcgi.conf;
# Apache2 で前に設定したときにここに入れたので
root /var/www/html;
また、ファイルのパーミッションが適切に設定されていないと 403 が返ってくる。リポジトリ記載のガイドとか、nginxで403を回避するために、パブリックファイルの権限についておさらい - Qiita とかを参考にしつついじる。
Apache2 で動かしたときの情報記載のものは以下の感じ。詳細はリンク先を。
こんな感じで動いた。
ただいまコメントを受けつけておりません。