玲玲酱学习java的奇妙之旅 2021-12-29 16:26 采纳率: 77.8%
浏览 68
已结题

想通过服务器进行文件下载,配置了nginx,访问不到文件,问题在网上搜不到,不知道怎么改

问题 黑窗口输入nginx -t,报错

nginx -t
nginx: [warn] "user" is not supported, ignored in F:\nginx\nginx-1.12.2/conf/nginx.conf:7
nginx: [emerg] CreateFile() "F:\nginx\nginx-1.12.2/conf/proxy.conf" failed (2: The system cannot find the file specified) in F:\nginx\nginx-1.12.2/conf/nginx.conf:40
nginx: configuration file F:\nginx\nginx-1.12.2/conf/nginx.conf test failed

代码

error.log里面错误日志为:
2021/12/29 15:43:47 [warn] 19720#14804: "user" is not supported, ignored in F:\nginx\nginx-1.12.2/conf/nginx.conf:7
2021/12/29 15:43:47 [emerg] 19720#14804: CreateFile() "F:\nginx\nginx-1.12.2/conf/proxy.conf" failed (2: The system cannot find the file specified) in F:\nginx\nginx-1.12.2/conf/nginx.conf:40


#在nginx.conf文件的第一行一般是设置用户的地方(编译安装nginx时的参数--user=也是指定用户的地方),如 user www www;
#如不指定nginx默认用户是nobody. 这里用户的设置又有什么意义呢?主要是指定执行nginx的worker process的用户,
#linux里所有程序都是文件,都具有权限问题,这个指定的用户对特定的文件有没有权限访问或执行,就是这个用户的意义。
#user  nobody;
#worker_processes  1;
#定义Nginx运行的用户和用户组
user  www www;
#nginx进程数,建议设置为等于CPU总核心数。
worker_processes auto;

#全局错误日志定义类型,[ debug | info | notice | warn | error | crit ]
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#nginx的error_log类型如下(从左到右:debug最详细 crit最少): 
#[ debug | info | notice | warn | error | crit ] 
#例如:error_log logs/nginx_error.log  crit; 
#解释:日志文件存储在nginx安装目录下的 logs/nginx_error.log ,错误类型为 crit ,也就是记录最少错误信息; 
#注意error_log off并不能关闭日志记录功能,它将日志文件写入一个文件名为off的文件中,如果你想关闭错误日志记录功能,应使用以下配置: 
#error_log /dev/null crit; 
error_log  logs/error.log;

#进程pid文件
#pid        logs/nginx.pid;
pid        logs/nginx.pid;
worker_rlimit_nofile 51200;

#worker_connections  1024;
events {
     #use epoll;
     worker_connections 51200;
     multi_accept on;
}

http
    {
        #文件扩展名与文件类型映射表
        include       mime.types;
        #include luawaf.conf;
        include proxy.conf;
        
        #默认文件类型
        default_type  application/octet-stream;
        
        #保存服务器名字的hash表是由指令server_names_hash_max_size 和server_names_hash_bucket_size所控制的。
        #参数hash bucket size总是等于hash表的大小,并且是一路处理器缓存大小的倍数。在减少了在内存中的存取
        #次数后,使在处理器中加速查找hash表键值成为可能。如果hash bucket size等于一路处理器缓存的大小,那么
        #在查找键的时候,最坏的情况下在内存中查找的次数为2。第一次是确定存储单元的地址,第二次是在存储单元中
        #查找键 值。因此,如果Nginx给出需要增大hash max size 或 hash bucket size的提示,那么首要的是增大前一个参数的大小.
        server_names_hash_bucket_size 512;
        
         #客户端请求头部的缓冲区大小。这个可以根据你的系统分页大小来设置,一般一个请求的头部大小不会超过1k,
         #不过由于一般系统分页都要大于1k,所以这里设置为分页大小。分页大小可以用命令getconf PAGESIZE取得。
        client_header_buffer_size 32k;
        
        #客户请求头缓冲大小。nginx默认会用client_header_buffer_size这个buffer来读取header值,
        #如果header过大,它会使用large_client_header_buffers来读取。
        large_client_header_buffers 4 32k;
        
        #设定通过nginx上传文件的大小
        client_max_body_size 50m;
        
        #开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为 on,如果用来进行下载等
        #应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成off。
        #sendfile指令指定 nginx 是否调用sendfile 函数(zero copy 方式)来输出文件,对于普通应用,必须设为on。如果用来进行下载
        #等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络IO处理速度,降低系统uptime。
        sendfile   on;
        
        #此选项允许或禁止使用socke的TCP_CORK的选项,此选项仅在使用sendfile的时候使用
        tcp_nopush on;

        #长连接超时时间,单位是秒
        keepalive_timeout 60;

        tcp_nodelay on;
        
        #FastCGI相关参数是为了改善网站的性能:减少资源占用,提高访问速度。下面参数看字面意思都能理解。
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;
        fastcgi_intercept_errors on;

        #gzip模块设置
        gzip on;#开启gzip压缩输出
        gzip_min_length  1k; #最小压缩文件大小
        gzip_buffers     4 16k;#压缩缓冲区
        gzip_http_version 1.1; #压缩版本(默认1.1,前端如果是squid2.5请使用1.0)
        gzip_comp_level 2;#压缩等级
        #压缩类型,默认就已经包含textml,所以下面就不用再写了,写上去也不会有问题,但是会有一个warn。
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        #开启限制IP连接数的时候需要使用
        #limit_zone crawler $binary_remote_addr 10m;
        limit_conn_zone $binary_remote_addr zone=perip:10m;
        limit_conn_zone $server_name zone=perserver:10m;

        server_tokens off;
        access_log off;
# 管理后台(正式)
server {
    listen       8090;  #配置监听端口
    server_name  111.229.130.227; #配置域名
    #rewrite ^(.*)$ https://$host$1; #将所有HTTP请求通过rewrite指令重定向到HTTPS。
    location / {
        root  /xingtaiquan/html/dist; #服务默认启动目录
        index  index.html index.htm; #默认访问文件
        try_files $uri $uri/ /index.html; #vue官方推荐方法,用于解决页面刷新404
        }    
    # location /api/ { #需要代理的api地址
    #     proxy_pass http://localhost:8595/api/;
    # }
    location /prod-api/{
        proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://localhost:9090/;
        }
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
      error_page  404              /404.html;  # 项目根目录配置404页面
        # 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$ { #请求的url过滤,正则匹配,~为区分大小写,~*为不区分大小写。
        #    root           html; #根目录
        #    fastcgi_pass   127.0.0.1:9000; #请求转向定义的服务器列表
        #    fastcgi_index  index.php; # 如果请求的Fastcgi_index URI是以 / 结束的, 该指令设置的文件会被附加到URI的后面并保存在变量$fastcig_script_name中
        #    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;
        #}
    }
    # 管理后台(测试)
server {
    listen       8091;  #配置监听端口
    server_name  111.229.130.227; #配置域名
        #rewrite ^(.*)$ https://$host$1; #将所有HTTP请求通过rewrite指令重定向到HTTPS。
    location / {
        root  /xingtaiquan/测试/html/dist; #服务默认启动目录
        index  index.html index.htm; #默认访问文件
        try_files $uri $uri/ /index.html; #vue官方推荐方法,用于解决页面刷新404
        }    
        # location /api/ { #需要代理的api地址
        #     proxy_pass http://localhost:8595/api/;
        # }
    location /prod-api/{
          proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://localhost:8080/;
            }
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
    error_page  404              /404.html;  # 项目根目录配置404页面
        # 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$ { #请求的url过滤,正则匹配,~为区分大小写,~*为不区分大小写。
        #    root           html; #根目录
        #    fastcgi_pass   127.0.0.1:9000; #请求转向定义的服务器列表
        #    fastcgi_index  index.php; # 如果请求的Fastcgi_index URI是以 / 结束的, 该指令设置的文件会被附加到URI的后面并保存在变量$fastcig_script_name中
        #    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;
        #}
    }
    
    # 后台代码测试
server {
    listen       8011;  #配置监听端口
    server_name  111.229.130.227; #配置域名
    location /{
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://localhost:8080/;
            }
    }
    
    # 后台代码正式
server {
    listen       8010;  #配置监听端口
    server_name  111.229.130.227; #配置域名
    location /{
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://localhost:9090/;
    }
}
    # 下载
server{
      listen   9990;需要监听的端口号(页面请求的)
      server_name   192.168.1.186;    # 服务器的ip得知
              location /FFOutput{# 需要代理的路径
              {
                alias D:/FFOutput;#指定文件存放路径(页面请求上面代理的路径会转发到这)
                autoindex on;
                }
             error_page   500 502 503 504  /50x.html;
             location = /50x.html {
                root   html;
             }
            location = /404.html {
            root   html;
            index  index.html index.htm;
                }
            }
    
}
server
    {
        listen 888;
        server_name phpmyadmin;
        index index.html index.htm index.php;
        root  /www/server/phpmyadmin;
            location ~ /tmp/ {
                return 403;
            }

        #error_page   404   /404.html;
        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }
include /www/server/panel/vhost/nginx/*.conf;
}













  • 写回答

2条回答 默认 最新

  • IT民工金鱼哥 运维领域新星创作者 2021-12-29 20:41
    关注

    先说你第一个问题:"user" is not supported, ignored in F:\nginx\nginx-1.12.2/conf/nginx.conf:7
    这里提示你大概第7行的地方,配置的用户不支持,user的配置项,你配置了www www 用户和组,那你应该对应要修改nginx程序目录里面的用户和组,否则,是没权限启动相关的,而你是 win机器,官网默认的配置是 #user nobody;


    至于第二个问题,"F:\nginx\nginx-1.12.2/conf/proxy.conf" failed (2: The system cannot find the file specified) in F:\nginx\nginx-1.12.2/conf/nginx.conf:40
    在配置文件大概40行,你设置了: include proxy.conf; 但如果你路径当中,没F:\nginx\nginx-1.12.2/conf/proxy.conf 文件的话,就肯定报错,需要你明确这文件是否存在,用来做什么? 没有就直接删除,有的话 ,指定正确的路径。
    稳定版本默认配置是
    http {
    include mime.types;
    default_type application/octet-stream;
    所以,明显你添加了 另外的包含配置。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 1月7日
  • 已采纳回答 12月30日
  • 修改了问题 12月29日
  • 创建了问题 12月29日

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站