0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Nginx: UTF-8 のテキストファイルを表示する

Posted at

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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?