我在项目根
中的`nginx.conf中有以下内容location / {
try_files $uri $uri/ /index.php?$query_string;
}
但只有在/
路径有效时,所有其他路径才会出现404错误。
如何使用nginx使Laravel在heroku上运行?
答案 0 :(得分:10)
这最终为我工作: Procfile:
web: vendor/bin/heroku-php-nginx -C nginx.conf public/
nginx.conf
location / {
# try to serve file directly, fallback to rewrite
try_files $uri @rewriteapp;
}
location @rewriteapp {
# rewrite all to app.php
rewrite ^(.*)$ /index.php$1 last;
}
答案 1 :(得分:-1)
您缺少fastcgi_*
指令;在你的location
指令后尝试这个:
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
来源:How to Install Laravel with an Nginx Web Server on Ubuntu 14.04