简体   繁体   English

GAE,无法使PHP正常工作

[英]GAE, can't get PHP to work

I need to set up a simple page on GAE, this is for someone who wants free hosting, basically. 我需要在GAE上设置一个简单的页面,这基本上是给那些想要免费托管的人的。 The page has a contact form, and I wrote a script in PHP. 该页面有一个联系表,我用PHP编写了一个脚本。 Ie: index.html, form action calls contact.php. 即:index.html,表单操作调用contact.php。 Although placing the code on the index.html and calling that instead produced no results, anyway. 尽管将代码放在index.html上并进行调用,但仍然没有任何结果。

I can't figure out how to make PHP work on GAE. 我不知道如何使PHP在GAE上运行。 I tried changing the app.yaml settings several times, and either PHP is not recognized at all (even something simple like 我尝试几次更改app.yaml设置,并且根本无法识别PHP(即使是简单的东西,例如

<?php echo "test"; ?> 

produces no results) or the browser tries to force download the script. 不会产生任何结果),或者浏览器尝试强制下载脚本。

Here's my current/last app.yaml: 这是我当前/最近的app.yaml:

application: [myappidentifier]
version: 1
runtime: php
api_version: 1

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

- url: /contact.php*
  script: contact.php

- url: /(.*\.(gif|png|jpg|svg|ico|js|css))
  static_files: \1
  upload: (.*\.(gif|png|jpg|svg|ico|js|css))

I'm sure this is all my fault, somehow. 我肯定这都是我的错。 :) How can I fix this so PHP works as intended on GAE? :)如何解决此问题,使PHP在GAE上可以正常工作?

Thank you for your time. 感谢您的时间。


EDIT: Well, nix the PHP mail() approach, they've disabled it on GAE, it seems? 编辑:好吧,排除了PHP mail()方法,他们已经在GAE上禁用了它,看来吗? https://developers.google.com/appengine/docs/php/mail/ https://developers.google.com/appengine/docs/php/mail/

But still, PHP in general doesn't seem to be working with my current setup. 但是,总体而言,PHP似乎不适用于我当前的设置。 Thanks for any help! 谢谢你的帮助!

You have an unnecessary * in your handler for contact.php, try changing it to: 您的contact.php处理程序中有一个不必要的*,请尝试将其更改为:

- url: /contact.php
  script: contact.php

Also, the more common way of working on AppEngine, it not to use file extensions for scripts, so change your handler to: 另外,在AppEngine上使用的更常见的方法是,不对脚本使用文件扩展名,因此将处理程序更改为:

- url: /contact
  script: contact.php

And then change your links and form destinations to /contact instead of /contact.php 然后将您的链接和表单目标更改为/ contact而不是/contact.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM