首页 > 解决方案 > 为什么找不到我的 php 页面?我的 yaml 文件有问题吗?

问题描述

我目前正在开发一个界面,以便在谷歌云平台上对我的 mySQL 数据库运行 SQL 查询。我有 PHP、HTML 和 YAML 文件。我已经启动了我的 HTML,但由于某种原因,每次我尝试运行查询时,我都会被带到这个页面:HTML 错误 500

我不认为是 PHP 或 HTML 是问题,因为当我添加一个测试 HTML 按钮时,它在我的本地机器上工作。我的 yaml 文件是这样的:

service: default
runtime: php55

handlers:

- url: /(.+\.php)$
  script: \1

- url: /$
  static_files: index.html
  upload: index.html

- url: /(.*)
  static_files: www/\1
  upload: www/(.*)

有谁知道我在这个配置中做错了什么?我的 php 文件名为 sql.php,主 html 文件名为 index.html 谢谢!

标签: phphtmlmysqlgoogle-app-enginegoogle-cloud-platform

解决方案


You would also need to define your environment variables in the app.yaml file.

Here is an example from GCP GitHub repository:

# [START gae_php_mysql_env]
env_variables:
  # Replace USER, PASSWORD, DATABASE, and CONNECTION_NAME with the
  # values obtained when configuring your Cloud SQL instance.
  MYSQL_DSN: mysql:unix_socket=/cloudsql/INSTANCE_CONNECTION_NAME;dbname=DATABASE
  MYSQL_USER: USER
  MYSQL_PASSWORD: PASSWORD
# [END gae_php_mysql_env] 

Remember - storing secrets in plaintext is potentially unsafe. Consider using something like https://cloud.google.com/kms/ to help keep secrets secret.


推荐阅读