せかいや

いまいるここを、おもしろく http://sekai-in-the-box.appspot.com/

【GAE】app.yaml  static_filesでの指定は全体に適応される・・・

 
むちゃくちゃ!
むちゃくちゃはまったよ!

ふえーん

現象

サブフォルダにおいたphpファイルが認識されない。
GAEでPHPを実行しようとすると500エラー。
f:id:sekaiya:20131018160213j:plain

Error: Server Error
The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error message and the query that caused it.

 
 
しかもエラーログには特に有益な情報が無い・・
f:id:sekaiya:20131018160254j:plain

app.yamlの記載はこういう感じ。

- url: /.*
  script: com/index.php

 
ルート直下に置くと見える。

- url: /.*
  script: index.php

原因

phpファイルを静的コンテンツとしてアップしていたため。



気づいたきっかけはデプロイログ。

06:23 PM Scanning files on local disk.
Could not guess mimetype for com/index.php.  Using application/octet-stream.
Could not guess mimetype for com/inc/about.inc.  Using application/octet-stream.
Could not guess mimetype for com/inc/contact.inc.  Using application/octet-stream.
Could not guess mimetype for com/inc/history.inc.  Using application/octet-stream.

 

comフォルダの下を静的リソースと認識している

phpファイル(com/index.php)なのに、
静的ファイルのアップロード時に必要なmimetype を見にいっている。

これは怪しいと思って色々探していたら、同じ現象の人を発見!
Cant deploy GAE Go app from Windows

 
なるほど><
app.yamlの記述で先にstatic_dir、static_files として指定すると、
指定したものはすべて静的ファイルとして扱われてしまう。

今のapp.yamlの記述はこう。
この「ココ!」でcom直下のファイルがすべて
静的ファイルとして認識されてしまっていた。

handlers:
- url: /favicon.ico
  static_files: static/images/favicon.ico
  upload: com/img/favicon.ico

- url: /css
  static_dir: com/css

- url: /js
  static_dir: com/js

- url: /img
  static_dir: com/img

- url: /(inc.*)
  static_files: com/\1    #<= ココ!
  upload: com/(.*)
  
- url: /
  script: com/index.php

- url: /.*
  script: com/index.php

- url: /.*
  static_files: com/index.html
  upload: com/index.html

■修正後

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


動いたー。

長かった。。。