如何配置nginx以观察laravel创建的动态创建的目录?
对于运行vesta控制面板的ubuntu 18.04下的laravel动态创建的子目录,nginx成功加载了网站根目录中的内容,但未成功加载laravel动态创建的目录中的内容。例如,由兰花管理面板动态创建的位于somesite.com/dashboard
的子目录不会加载css。
任何帮助将不胜感激。
/ home / user / conf / web / somesite.com.nginx.conf:
server {
listen some-server-ip:80;
server_name somedomain.com www.somedomain.com;
root /home/user/web/somedomain.com/public;
index index.html index.htm index.php;
charset utf-8;
access_log /var/log/nginx/domains/somesite.com.log combined;
access_log /var/log/nginx/domains/somesite.com.bytes bytes;
error_log /var/log/nginx/domains/somesite.com.error.log error;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location / {
try_files $uri $uri/ /index.php?$query_string;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
location /error/ {
alias /home/user/web/somedomain.com/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
location /vstats/ {
alias /home/user/web/somedomain.com/stats/;
include /home/user/conf/web/somedomain.com.auth*;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include /home/user/conf/web/nginx.somedomain.com.conf*;
}
兰花完全依赖Laravel设置
server {
listen 80;
server_name example.com;
root /example.com/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
请注意documentation。