Nginx の Default 設定で UTF-8 のテキストファイルを表示すると、文字化けをお越します。それを解決する設定です。
設定ファイル
/etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
charset UTF-8;
root /var/www/html;
index index.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
Python の CGI を使う時の設定です。
/etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
charset UTF-8;
root /var/www/html;
index index.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.py$ {
gzip off;
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.py;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
設定が正しいかどうかの確認
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Nginx の再起動
sudo systemctl restart nginx