【问题标题】:Goole App Engine - Deployed PHP app does not recognize php filesGoogle App Engine - 部署 PHP 应用程序无法识别 php 文件
【发布时间】:2020-04-17 08:18:27
【问题描述】:

我已经部署了我的网络应用程序 - 谷歌应用程序引擎中的一个 php 应用程序。 App.yaml 代码

runtime: php55
api_version: 1
#threadsafe: true

handlers:
- url: /
  static_files: www/index.html
  upload: www/index.html

- url: /mail
  static_dir: www/mail
# Serve php scripts.
- url: /mail/.*
  script: www/mail/mailsender_1.php
- url: /(.*)$
  static_files: www/\1
  upload: www/(.*)

但是,当 /mail/mailsender_1.php 从 javascript - ajax 调用中调用时,它不会将 mailsender_1.php 识别为 php 脚本。我花了整整一天的时间进行调试。任何帮助将不胜感激。

【问题讨论】:

  • 通过查看您的问题并与此community question 进行比较,我发现问题可能是最终处理程序,而不是/mail/.* 处理程序。接受的答案表明,最终处理程序使部署认为您的 www/ 目录中的所有文件都是静态的且可上传的,包括 .php 脚​​本。我的建议是将upload: www/(.*) 指令更改为upload: www/(.*)\.jpg 或您必须尝试的任何其他文件扩展名。试试看,让我知道它是否有效。
  • 感谢您的指点,我可以更改我的 app.yaml 文件运行时:php55 api_version: 1 #threadsafe: true handlers: - url: / static_files: www/index.html 上传:www /index.html # 提供 php 脚本。 - url: /mail/.* 脚本: www/mail/mailsender_1.php - url: /(.*)$ static_files: www/\1 上传: www/(.*)\.(js|css|png|jpg |jpeg|地图|woff)
  • 所以它确实有效?我会将所有这些添加到正确的答案中,以便社区可以看到问题已得到解决,并且如果是这种情况,您可以接受/投票。
  • 请考虑接受并支持下面提供的答案,以便社区可以看到您得到了充分的帮助。

标签: php google-app-engine


【解决方案1】:

通过查看您的问题并与此community question 进行比较,我想到您面临的问题是由于/(.*)$ 处理程序,而不是/mail/.* 处理程序。

该帖子上接受的答案表明您的/(.*)$ 处理程序使部署认为您的www/ 目录中的所有文件都是静态的且可上传的,包括.php 脚本。

根据 cmets,我的建议是将 upload: www/(.*) 指令更改为 upload: www/(.*)\.(js|css|png|jpg|jpeg|map|woff),因为它将适合您拥有的所有文件扩展名。

因此您的处理程序部分应如下所示:

handlers:
- url: /
  static_files: www/index.html
  upload: www/index.html

- url: /mail
  static_dir: www/mail
# Serve php scripts.
- url: /mail/.*
  script: www/mail/mailsender_1.php
- url: /(.*)$
  static_files: www/\1
  upload: www/(.*)\.(js|css|png|jpg|jpeg|map|woff)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-16
    相关资源
    最近更新 更多