Nginx

インストール忘備録

Nginx Install
https://www.nginx.com/resources/wiki/start/topics/tutorials/install/

sudo vi /etc/apt/sources.list.d/nginx.list
======================================
deb https://nginx.org/packages/ubuntu/ jammy nginx
deb-src https://nginx.org/packages/ubuntu/ jammy nginx
======================================
sudo apt update
## Err:6 https://nginx.org/packages/ubuntu jammy InRelease
## The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ABCD12345678ABCD
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABCD12345678ABCD
sudo apt update
sudo apt install nginx
#sudo systemctl enable nginx
sudo systemctl start nginx

uWSGI Install
https://uwsgi-docs.readthedocs.io/en/latest/Install.html

sudo apt install build-essential python3-dev
sudo pip install uwsgi
vi hello.py
======================================
import dash
from dash import dcc
from dash import html

app = dash.Dash()
server = app.server
app.layout = html.Div(children=[
  html.H1(children='Hello Dash'),
  html.Div(children='Dash Framework'),
  dcc.Graph(
    id='sample',
    figure={
      'data': [
        {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'ABC'},
        {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': 'DEF'},
      ],
      'layout': {
        'title': 'Sample Graph'
      }
    }
  )
])

Internal Test

uwsgi --http='192.168.123.123:9980' --chmod-socket='666' --master --enable-threads --mount='/=hello:server'
curl -i 192.168.123.123:9980

File Socket for Nginx

uwsgi --socket='/tmp/uwsgi.sock' --chmod-socket='666' --master --enable-threads --mount='/=hello:server'

No python application found のエラーが出る場合は mount の引数で指定したモジュールが問題なく実行できるか確認

sudo vi /etc/nginx/conf.d/app.conf
======================================
server {
    listen 8080;
    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi.sock;
    }
}
======================================
sudo systemctl restart nginx

Connect to Dash via uWSGI and Nginx
http://192.168.123.123:8080/

エラーが出る場合は /var/log/nginx/error.log を確認する
502 Bad Gateway の場合はソケットファイルの権限設定が怪しい
404 Not Found の場合はパス指定が怪しい

Daiphys is a professional-service company for research and development of leading-edge technologies in science and engineering.
Get started accelerating your business through our deep expertise in R&D with AI, quantum computing, and space development; please get in touch with Daiphys today!

Name*


Email*


Message*




* Indicates required field

Daiphys Technologies LLC - https://www.daiphys.com/

  • Last modified: 2022/08/22 06:22
  • by Daiphys