Thr*_*nts 1 php deployment heroku laravel
尝试将Laravel 5应用程序部署到Heroku时,我遇到了一个非常奇怪的错误.如果我尝试访问我的根域,https://my-app.herokuapp.com它工作正常.但是,如果我尝试访问和其他域名/也是https://my-app.herokuapp.com/api/v1/users 它给我一个404找不到.Heroku实际上是试图转到文件夹/ api/v1/users而不是读取路由文件.
这是我的Procfile:
web: vendor/bin/heroku-php-nginx public/
现在,如果我尝试相同的东西,但使用Apache服务器,它工作正常:
web: vendor/bin/heroku-php-apache2 public/
小智 7
https://devcenter.heroku.com/articles/custom-php-settings
使用自定义应用程序级别Nginx配置
在Heroku在Nginx启动期间使用的默认服务器级配置文件中,它包含一个非常简单的默认应用程序级配置文件.您可以使用自定义配置替换此文件.例如,要将Nginx配置为对Symfony2应用程序使用一些重写规则,您需要在应用程序的根目录中创建一个nginx_app.conf,其中包含以下内容:
location / {
# try to serve file directly, fallback to rewrite
try_files $uri @rewriteapp;
}
location @rewriteapp {
# rewrite all to app.php
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
try_files @heroku-fcgi @heroku-fcgi;
internal;
}
Run Code Online (Sandbox Code Playgroud)
对于laravel.
在根目录nginx_app.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;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
try_files @heroku-fcgi @heroku-fcgi;
internal;
}
Run Code Online (Sandbox Code Playgroud)
在Procfile中:
web: vendor/bin/heroku-php-nginx -C nginx_app.conf /public
Run Code Online (Sandbox Code Playgroud)
在http://laravel.com/docs/4.2/installation#pretty-urls上找到了解决方案
我有同样的问题。基本上,我刚刚在 /public 文件夹中添加了 .htaccess 文件,现在一切正常。
| 归档时间: |
|
| 查看次数: |
1858 次 |
| 最近记录: |