2

我正在使用 Docker、Nginx 和 Lumen 构建一个 Web 应用程序。我已经完成了文件上传功能,一切正常。但是,当我尝试从 URL Lumen 访问上传的文件时,我会抛出NotFoundHttpException.

我已经使用以下命令在存储和公用文件夹之间创建了符号链接:

    ln -s /var/www/storage/app/public /var/www/public/storage

这是我的 Nginx 配置:

    http {
        index index.html index.php;
        sendfile on;
        tcp_nopush on;
        gzip on;
        gzip_proxied any;
        gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
        gzip_vary on;
        gzip_disable "msie6";

        server {
            disable_symlinks off;
            listen 80;
            listen [::]:80;
            server_name api.uhire.test www.api.uhire.test;
            root /var/www/public;

            location / {
                try_files $uri $uri/ /index.php?$query_string;
            }

            location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass php:9000;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_path_info;
            }
        }
    }

我的文件路径是storage/app/public/customers/1/test.jpeg. 但是,如果我http://api.uhire.test/storage/customers/1/test.jpeg在浏览器的 URL 栏中键入,则无法访问。

4

0 回答 0