gpt4 book ai didi

php - 在 Heroku 上部署 PHP 项目

转载 作者:可可西里 更新时间:2023-11-01 00:08:48 25 4
gpt4 key购买 nike

我已经在 heroku 上成功部署了我的 PHP 项目,但问题是每当我输入“Heroku Open”以加载网页 url 时,我都会收到以下错误:

 Forbidden
You don't have permission to access / on this server.

我知道问题可能出自服务器配置、我的 ht-access,甚至是 Apache 配置,我已经尝试进行各种更改,但到目前为止都没有奏效,这里是 heroku 日志:

015-03-15T10:47:30.266691+00:00 heroku[api]: Release v2 created by x@x.x
2015-03-15T10:50:02.189549+00:00 heroku[api]: Scale to web=1 by x@x.x
2015-03-15T10:50:02.262334+00:00 heroku[api]: Deploy d388ddf by x@x.x
2015-03-15T10:50:02.262334+00:00 heroku[api]: Release v3 created by x@x.x
2015-03-15T10:50:08.597918+00:00 heroku[web.1]: Starting process with command `vendor/bin/heroku-php-apache2`
2015-03-15T10:50:10.812072+00:00 app[web.1]: Starting php-fpm...
2015-03-15T10:50:10.620318+00:00 app[web.1]: Optimzing defaults for 1X dyno...
2015-03-15T10:50:10.802110+00:00 app[web.1]: 4 processes at 128MB memory limit.
2015-03-15T10:50:12.815707+00:00 app[web.1]: Starting httpd...
2015-03-15T10:50:13.132692+00:00 heroku[web.1]: State changed from starting to up
2015-03-15T10:50:38.639895+00:00 heroku[api]: Scale to web=1 by x@x.x
2015-03-15T10:50:49.465371+00:00 heroku[router]: at=info method=GET path="/" host=boiling-bastion-7861.herokuapp.com request_id=92b6872e-c060-4e06-8ede-5d44ea335ada fwd="175.140.77.229" dyno=web.1 connect=1ms service=3ms status=403 bytes=387
2015-03-15T10:50:49.465802+00:00 app[web.1]: 10.123.194.135 - - [15/Mar/2015:10:50:49 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
2015-03-15T10:50:49.465396+00:00 app[web.1]: [Sun Mar 15 10:50:49.463558 2015] [autoindex:error] [pid 117:tid 140423049713408] [client 10.123.194.135:31742] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (home.php) found, and server-generated directory index forbidden by Options directive
2015-03-15T10:50:49.907445+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=boiling-bastion-7861.herokuapp.com request_id=76865ea0-628f-426f-8bad-5507aa052fb4 fwd="175.140.77.229" dyno=web.1 connect=1ms service=5ms status=200 bytes=3964
2015-03-15T10:50:49.906266+00:00 app[web.1]: 10.123.194.135 - - [15/Mar/2015:10:50:49 +0000] "GET /favicon.ico HTTP/1.1" 200 3754 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
2015-03-15T10:53:30.128901+00:00 heroku[router]: at=info method=GET path="/" host=boiling-bastion-7861.herokuapp.com request_id=56038276-5eb7-40ad-8615-cc695a72cdcb fwd="175.140.77.229" dyno=web.1 connect=1ms service=2ms status=403 bytes=387
2015-03-15T10:53:30.129676+00:00 app[web.1]: 10.91.13.225 - - [15/Mar/2015:10:53:30 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
2015-03-15T10:53:30.129331+00:00 app[web.1]: [Sun Mar 15 10:53:30.128673 2015] [autoindex:error] [pid 102:tid 140423284651776] [client 10.91.13.225:15561] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (home.php) found, and server-generated directory index forbidden by Options directive
2015-03-15T10:53:30.686329+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=boiling-bastion-7861.herokuapp.com request_id=9bfc7392-7f31-49ff-831a-55dbd0812914 fwd="175.140.77.229" dyno=web.1 connect=3ms service=4ms status=200 bytes=3964
2015-03-15T10:53:30.686175+00:00 app[web.1]: 10.91.13.225 - - [15/Mar/2015:10:53:30 +0000] "GET /favicon.ico HTTP/1.1" 200 3754 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
2015-03-15T11:06:22.231815+00:00 heroku[router]: at=info method=GET path="/" host=boiling-bastion-7861.herokuapp.com request_id=3a2df217-758f-469c-884a-3f27072dda7d fwd="175.140.77.229" dyno=web.1 connect=4ms service=7ms status=403 bytes=387
2015-03-15T11:06:22.228756+00:00 app[web.1]: 10.93.25.70 - - [15/Mar/2015:11:06:22 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
2015-03-15T11:06:22.228440+00:00 app[web.1]: [Sun Mar 15 11:06:22.227460 2015] [autoindex:error] [pid 104:tid 140423183963904] [client 10.93.25.70:29123] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (home.php) found, and server-generated directory index forbidden by Options directive
2015-03-15T11:06:22.710597+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=boiling-bastion-7861.herokuapp.com request_id=ad006b2f-00fe-426e-81f0-e2a8d8e9e457 fwd="175.140.77.229" dyno=web.1 connect=1ms service=10ms status=200 bytes=3964
2015-03-15T11:06:22.709151+00:00 app[web.1]: 10.93.25.70 - - [15/Mar/2015:11:06:22 +0000] "GET /favicon.ico HTTP/1.1" 200 3754 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36

可能的解决方案是什么?!任何考虑表示赞赏...

最佳答案

Apache 会在您的错误日志中告诉您问题出在哪里(为了便于阅读,我将其封装):

2015-03-15T10:50:49.465396+00:00 app[web.1]: [Sun Mar 15 10:50:49.463558 2015]
[autoindex:error] [pid 117:tid 140423049713408] [client 10.123.194.135:31742]
AH01276: Cannot serve directory /app/: No matching DirectoryIndex (home.php) found,
and server-generated directory index forbidden by Options directive

您显然在 .htaccess 文件中的某处有 DirectoryIndex home.php,但是没有 home.php,所以当您尝试转到 /,它找不到该文件(当您只请求目录本身 / 时它会使用),并且列出目录内容(不是你想要什么)在默认配置中是不允许的。

因此,您要么需要使用您的代码创建一个 home.php,要么更改该 .htaccess 以删除 DirectoryIndex 语句,以便您的 index.php/index.html(如果存在)得到服务,或者,如果您的 home.php 和其他所有内容不在根目录中您的项目,但位于 publicweb 之类的子目录中,define a document root using the documented argument in your Procfile command :

web: vendor/bin/heroku-php-apache2 public/

关于php - 在 Heroku 上部署 PHP 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29060475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com