win下 Nginx.conf 路径配置规范

使用win绝对路径

网上有种说法win下Nginx不能设置绝对路径,但我在Nginx-1.24.0下是设置成功的。

路径不能包含中文

使用C:软件Nginx 路径nginx报找不到文件错误

路径不能包含空格

使用C:Program FilesNginx 路径nginx报找不到文件错误。除非改成: C:ProgramFilesNginx

路径中的”n“会被识别换行

使用C:nginx 路径,nginx报找不到文件错误原因是,nginx会把n识别换行,最终路径被识别为:

C:
ginx

正确写法是:C:\nginx我们可以一律用双斜杠\代替单斜杠

​ 举个例子error_log配置如下

image-20230626114305988

nginx报错

image-20230626113822612

贴一段正确配置的Nginx.conf代码

worker_processes  1;

error_log  D:\nginx\logs\error.log info;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

	server {
		#监听443端口
		listen       443 ssl; 
		server_name  127.0.0.1;

		#ssl证书crt文件路径
		ssl_certificate     D:\SSLCertificate\server.crt;

		#ssl证书key文件路径
		ssl_certificate_key D:\SSLCertificate\server.key;

		location / {
			root   html;
			index  index.html index.htm;
			proxy_pass  http://127.0.0.1:7001;
			}
	}
}

原文地址:https://blog.csdn.net/guigenyi/article/details/131394565

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_48946.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注