无法下载文件laravel使用nginx(失败-网络错误)

时间:2019-04-16 09:26:38

标签: laravel nginx php-7.2

问题已解决!

我在nginx中检查error.log

2019/04/16 17:29:39 [crit] 12060#12060: *261 open() "/var/lib/nginx/fastcgi/6/05/0000000056" failed (13: Permission denied) while reading upstream, client: 118.70.67.64, server: govangtam.org, request: "GET /download HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "govangtam.org"

我通过用户运行PHP-FPM更改chown var / lib / nginx / fastcgi

sudo chown -R forge:forge /var/lib/nginx/fastcgi

------------------问题--------------------

我无法在laravel 5.7,nginx,php7.2存储中下载文件

我尚未找到原因,我在仍能正常工作的另一台服务器上使用代码。

下载错误Failed - Network errorFailed - File incomplete时。我使用nginx版本nginx / 1.14.2,Ubuntu 16.04

url:http://govangtam.org/download

路由器web.php

Route::get('download', function () {
  $file = storage_path('app').'/abc.mp3';
  return response()->download($file);
});

nginx domain.conf

server {
    listen 80;
    listen [::]:80;

    root /home/forge/govangtam.org/public;
    index index.php index.html index.htm;

    server_name govangtam.org www.govangtam.org;

    location / {
        #try_files $uri $uri/ =404;
    try_files $uri $uri/ /index.php$is_args$args;
    proxy_cache_revalidate on;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    }
}

nginx.conf

user forge;

worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {
    # Basic Settings
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;
    client_max_body_size 20M;

    server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # SSL Settings
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    # Logging Settings
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # Gzip Settings
    gzip on;
    gzip_disable "msie6";

    # Virtual Host Configs

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
proxy_read_timeout 950s;
map $http_upgrade $connection_upgrade {
default upgrade;
''      close;
}
}

0 个答案:

没有答案