LOADING

windows下nginx问题:[crit]796#7096:*1GetFileAttributesEx()"F:ginx1.12.2\html\dist"failed(123:Thefilename,directoryname,orvolumelabelsyntaxisincorrect),client:127.0.0.1,server:localho

错误信息:

2019/09/09 13:54:37 [crit] 796#7096: *1 GetFileAttributesEx() “F: ginx-1.12.2\html\dist” failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: localhost, request: “GET / HTTP/1.1”, host: “localhost:8081”

说明:本机windows环境下   玩nginx部署vue项目的时候, 访问http://localhost:8081/  出现了错误页面

windows下nginx问题:[crit]796#7096:*1GetFileAttributesEx()"F:ginx1.12.2\html\dist"failed(123:Thefilename,directoryname,orvolumelabelsyntaxisincorrect),client:127.0.0.1,server:localho

 

 然后我就去看日志,就是上边的错误信息。发现 错误信息中 应该是 nginx-1.12.2结果却是 ginx-1.12.2 。

原因:windows和linux不一样,windows中默认是 反斜杠\\\\\\\\\\\\\  而linux确是斜杠//////  结果根路径F:\nginx-1.12.2 中的  \n 就会被当成是换行,被转义处理。

解决办法:配置vue资源根目录的时候   F:\\nginx-1.12.2\html\dist     双反斜杠表示不转义。如果是linux就不会存在这个问题 我已经测试了

下边是windows的 nginx配置文件:

//

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
# ‘$status $body_bytes_sent “$http_referer” ‘
# ‘”$http_user_agent” “$http_x_forwarded_for”‘;

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 8081;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

#vue项目的根路径 windows是双反斜杠
root F:\\nginx-1.12.2\html\dist;
index index.html index.htm;

try_files $uri $uri/ /index.html;
}
#访问后台接口的代理
location /api/ {
proxy_pass http://localhost:8080/;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
#location ~ /\.ht {
# deny all;
#}
}

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}

# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

 

原文链接:https://www.cnblogs.com/xuchao0506/p/11491621.html
本文来源 爱码网,其版权均为 原网址 所有 与本站无关,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源。

© 版权声明

相关文章