Error 404 nginx - AGE php - 如何在 app.yaml 文件的处理程序属性中正确定义子文件夹?
Error 404 ngix - GAE php - How to properly define subfolders in the handlers attributes of app.yaml file?
我对 app.yaml 文件定义有一些问题。我曾尝试在 GAE 上部署一个简单的应用程序,但每次我尝试在 https://myapp.appspot.com/api/v1/validate:
访问我的应用程序时,我总是收到 404 错误
这里是文件夹结构:
- app.yaml
- 网络
- api
- v1
- 验证
- index.php
这是我的 app.yaml 代码:
runtime: php
env: flex
runtime_config:
document_root: web
handlers:
- url: /api/v1/validate/.*
script: index.php
我做错了什么?提前谢谢你
我成功部署了类似的设置。这是我的更改:
访问URL:https://YourProject.appspot.com/api/v1/validate/index.php
在index.php中修改第20行为
require_once __DIR__ . '/../../../../vendor/autoload.php';
在 app.yaml 添加处理程序为:
runtime: php
env: flex
runtime_config:
document_root: web
handlers:
- url: /api/v1/authenticate
script: /api/v1/authenticate/index.html
- url: /api/v1/userprofile
script: /api/v1/userprofile/index.php
它工作得很好。
为此,我只是按照Quickstart for PHP in the App Engine Flexible文档并将helloworld目录修改为
我的文件夹结构和你一模一样
更新
在查看了您的代码后,我成功地使用这些设置部署了一个应用程序
app.yaml
runtime: php
env: flex
runtime_config:
document_root: web
handlers:
- url: /api/v1/authenticate
script: /api/v1/authenticate/index.html
- url: /api/v1/userprofile
script: /api/v1/userprofile/index.php
index.php
<?php
include '../../utils.php';
require_once __DIR__ . '/../../../../vendor/autoload.php';
$app = new Silex\Application();
$app->get('/', function () {
return 'Hello World';
});
$app->get('/goodbye', function () {
return 'Goodbye World';
});
// @codeCoverageIgnoreStart
if (PHP_SAPI != 'cli') {
$app->run();
}
// @codeCoverageIgnoreEnd
return $app;
?>
我看到的是您没有以正确的方式处理 http 请求。您可以查看上面添加的 index.php,如果您将其中一个 index.php 代码替换为此代码,您将看到 yaml 文件将允许您在 https://YOUR_APP.devshell.appspot.com/api/v1/userprofile/index.php 连接到您的应用程序
我对 app.yaml 文件定义有一些问题。我曾尝试在 GAE 上部署一个简单的应用程序,但每次我尝试在 https://myapp.appspot.com/api/v1/validate:
访问我的应用程序时,我总是收到 404 错误这里是文件夹结构:
- app.yaml
- 网络
- api
- v1
- 验证
- index.php
- 验证
- v1
- api
这是我的 app.yaml 代码:
runtime: php
env: flex
runtime_config:
document_root: web
handlers:
- url: /api/v1/validate/.*
script: index.php
我做错了什么?提前谢谢你
我成功部署了类似的设置。这是我的更改:
访问URL:https://YourProject.appspot.com/api/v1/validate/index.php
在index.php中修改第20行为
require_once __DIR__ . '/../../../../vendor/autoload.php';
在 app.yaml 添加处理程序为:
runtime: php
env: flex
runtime_config:
document_root: web
handlers:
- url: /api/v1/authenticate
script: /api/v1/authenticate/index.html
- url: /api/v1/userprofile
script: /api/v1/userprofile/index.php
它工作得很好。
为此,我只是按照Quickstart for PHP in the App Engine Flexible文档并将helloworld目录修改为
我的文件夹结构和你一模一样
更新
在查看了您的代码后,我成功地使用这些设置部署了一个应用程序
app.yaml
runtime: php
env: flex
runtime_config:
document_root: web
handlers:
- url: /api/v1/authenticate
script: /api/v1/authenticate/index.html
- url: /api/v1/userprofile
script: /api/v1/userprofile/index.php
index.php
<?php
include '../../utils.php';
require_once __DIR__ . '/../../../../vendor/autoload.php';
$app = new Silex\Application();
$app->get('/', function () {
return 'Hello World';
});
$app->get('/goodbye', function () {
return 'Goodbye World';
});
// @codeCoverageIgnoreStart
if (PHP_SAPI != 'cli') {
$app->run();
}
// @codeCoverageIgnoreEnd
return $app;
?>
我看到的是您没有以正确的方式处理 http 请求。您可以查看上面添加的 index.php,如果您将其中一个 index.php 代码替换为此代码,您将看到 yaml 文件将允许您在 https://YOUR_APP.devshell.appspot.com/api/v1/userprofile/index.php 连接到您的应用程序