【发布时间】:2026-01-07 04:15:02
【问题描述】:
我已将我的项目压缩并上传到 AWS Beanstalk。然后我必须手动配置Document root,即:/api-test-beanstalk
我的索引文件位于这个目录中,所以:
zip --> api-test-beanstalk --> index.php
在 index.php 内部我试图读取位于同一个文件夹中名为 abc.php 的文件,所以我尝试了:
$file = '/api-test-beanstalk/abc.php';
echo file_get_contents($file);
$file = 'api-test-beanstalk/abc.php';
echo file_get_contents($file);
$file = '/abc.php';
echo file_get_contents($file);
$file = 'abc.php';
echo file_get_contents($file);
似乎没有任何效果,所有结果都会导致如下所示的错误:
Warning: file_get_contents(api-test-beanstalk/abc.php): failed to open stream: No such file or directory in /var/app/current/api-test-beanstalk/index.php on line 67
如何在 index.php 中读取 abc.php?这些文件在同一个文件夹中彼此相邻。
【问题讨论】:
-
您是否将 abc.php 与 index.php 一起提交?
-
@Tal 是的,它们位于 ZIP 文件夹中名为 api-test-beanstalk 的同一个文件夹中
-
没关系,找到答案了
标签: php amazon-elastic-beanstalk file-get-contents readfile