K.MIURA@OUC

The special secret of making dreams come true can be summarized in four C’s. They are Curiosity, Confidence, Courage, and Constancy. –Walt Disney

nginxと連携してPythonを動かす

[基本環境]
  • Ubuntu 18.04
  • nginx 1.14
[注意]
  • PythonでCGIは…と思う人にはお勧めしません
[nginxとfcgiwrapのインストール]
  1. sudo apt update
  2. sudo atp upgrade
  3. sudo apt install python3 nginx-full fcgiwrap vim
  4. sudo vi /etc/nginx/fcgiwrap.conf
  5. cd /var/www
  6. sudo mkdir cgi-bin
  7. sudo chmod 755 cgi-bin
  8. sudo vi /etc/nginx/sites-availabel/default
    server{…}の中に、include fcgiwrap.conf; を追加する
  9. sudo service nginx restart
  10. sudo service fcgiwrap restart
  11. cd cgi-bin
  12. sudo vi test.py
  13. sudo chmod 755 test.py
[CGIの動作確認]
  1. http://IPアドレス/cgi-bin/test.py
Read more →

nginxでBasic認証を有効にする

[基本環境]
  • Ubuntu 18.04
  • nginx 1.16
[apache2-utilsのインストール]
  1. sudo apt update
  2. sudo apt install apache2-utils
[.htpasswdの生成]
  1. cd /home/ユーザ名/
  2. mkdir web
    • webは任意のディレクトリ名で良い
  3. htpasswd -c /home/ユーザ名/web/.htpasswd user-id
    • user-idはBasic認証のユーザ名であり、任意のユーザ名で良い
[nginx.confの編集]
  1. cd /etc/nginx
  2. sudo vi nginx.conf
    • http{…}の中に、
      auth_basic “Your Auth Message”;
      auth_basic_user_file /home/ユーザ名/web/.htpasswd;
      を追加する
Read more →

ストリーミングサーバを立てる

[基本環境]
  • Debian 10.3.0 (amd64)
[参考サイト]
[nginxとrtmpのインストール]
  1. sudo apt update
  2. sudo apt upgrade
  3. sudo add-apt-repository ppa:nginx/stable
    • レポジトリ追加の際の確認事項に対しては、[Enter]を押す
  4. sudo apt install nginx libnginx-mod-rtmp
[rtmpの有効化]
  1. cd /etc/nginx
  2. sudo vi nginx.conf
    • hogelive(5行目)を自由に変更する
  3. sudo service nginx restart
[受付用index.htmlの作成]
  1. cd /var/www/html
  2. sudo vi index.html
    • hogeliveをnginx.confと同じものにする
    • ipアドレスをストリーミングサーバのIPアドレスにする
    • hogekeyを自由に変更する
[配信システムの構築]
  • mp4動画を配信するだけなら、以下の作業は必要ない
  • /var/www/html以下にディレクトリを作成して、mp4動画を保存する
  1. sudo apt-get install ffmpeg
  2. sudo add-apt-repository ppa:obsproject/obs-studio
  3. sudo apt-get update
  4. sudo apt-get install obs-studio
  5. obs
    • 配信先: rtmp://IPアドレス:1935/hogelive
    • ストリームキー: hogekey
[視聴者の操作]
  1. WEBブラウザで http://IPアドレス/ にアクセスする
Read more →