Linux文件编码问题
Linux修改文件报错
今天修改nginx的配置文件时:
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
lua_package_path "/usr/local/openresty/lualib/?.lua;;";
lua_package_cpath "/usr/local/openresty/lualib/?.so;;";
lua_shared_dict item_cache 150m;
#tomcat server
upstream tomcat-cluster {
hash $request_uri;
server 192.168.131.1:8081;
}
server {
listen 8081;
server_name localhost;
location /item {
proxy_pass http://tomcat-cluster;
}
location ~ /api/item/(\d+) {
default_type application/json;
content_by_lua_file lua/item.lua;
}
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
报错:
nginx: [emerg] unknown directive "default_type application/json" in /usr/local/openresty/nginx/conf/nginx.conf:34
用idea打开发现文件乱码,解决方法:
1.改成UTF-8编码
2.用高级代码编辑器打开文档,如idea,vscode等