nignx无法正常工作try_files CSS JS(laravel)

时间:2018-09-12 09:44:59

标签: laravel nginx

NGINX LOG Chrome Network

我设置了nginx。 路由没有问题。

css和js无法加载。 似乎在公用文件夹中只能识别索引。

我不知道我错过了什么或错字了。

server {
listen       80;
server_name  laravel.test;
root         /var/www/laravel/public;

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

location ~* \.(?:css|js)$ {
    expires 1y;
    access_log off;
    add_header Cache-Control "public";
}

location ~* \.(?:ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|webp|swf)$ {
    expires 1y;
    access_log off;
    add_header Cache-Control "public";
}

index index.html index.htm index.php;

charset utf-8;
error_page  404              /404.html;

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /var/www/html;
}

location ~ \.php$ {
    fastcgi_pass   php:9000;
    fastcgi_index  index.php;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include        fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 16 16k;
    fastcgi_connect_timeout 600s;
    fastcgi_send_timeout 600s;
    fastcgi_read_timeout 600s;
}

location ~ /\.ht {
    deny  all;
}

access_log /var/log/nginx/laravel-access.log;
error_log  /var/log/nginx/laravel-error.log error;

}

本地php -S本地主机:5000很好。

php代码似乎不是问题

++ ps

http://laravel.test 200

http://laravel.test/home 200

http://laravel.test/css/test.php 200

http://laravel.test/css/app.css 404

http://laravel.test/js/test.php 200

http://laravel.test/js/app.js 404

0 个答案:

没有答案