Laravel nginx.conf 使用官方 Heroku php 构建包?
Laravel nginx.conf with official Heroku php buildpack?
我的项目根目录中的`nginx.conf中有以下内容
location / {
try_files $uri $uri/ /index.php?$query_string;
}
但仅在 /
路径中有效,所有其他路径都出现 404 错误。
如何让 Laravel 在 heroku 上与 nginx 一起工作?
您缺少 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
这最终对我有用:
简介:
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 last;
}
我的项目根目录中的`nginx.conf中有以下内容
location / {
try_files $uri $uri/ /index.php?$query_string;
}
但仅在 /
路径中有效,所有其他路径都出现 404 错误。
如何让 Laravel 在 heroku 上与 nginx 一起工作?
您缺少 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
这最终对我有用: 简介:
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 last;
}