【发布时间】:2016-04-08 17:21:12
【问题描述】:
我得到了 Laravel 的 4.2 宅基地服务器 (nginx)。 所以,如果我在任何视图中这样写:
<script src="media/js/application.js"></script>
<link rel="icon" href="media/img/branding/favicon.png" type="image/x-icon">
<link rel="stylesheet" href="media/css/markdown.css">
它包含所有文件,但下面的代码不起作用(403错误):
<div style="background-image: url(media/img/image.jpg)"></div>
另外,如果我尝试直接访问 /public 中的某些文件夹/文件,它也会返回 403。为什么?这是我的 nginx 站点配置(事实上这是一个自动生成的宅基地配置):
vagrant@homestead:~/work/Timetable$ cat /etc/nginx/sites-enabled/timetable.dev
server {
listen 80;
listen 443 ssl;
server_name timetable.dev;
root "/home/vagrant/work/Timetable/public";
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; }
access_log off;
error_log /var/log/nginx/timetable.dev-error.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
ssl_certificate /etc/nginx/ssl/timetable.dev.crt;
ssl_certificate_key /etc/nginx/ssl/timetable.dev.key;
}
【问题讨论】:
标签: http laravel nginx laravel-4 homestead