2016-12-11 13 views
2

私はGAEを使用して開発しています。私はクラウドでアプリケーションをデプロイするときに問題に直面しています。PHP GAINのYaml構造

>エラー:見つからないこのサーバーでは、要求されたURL /が見つかりませんでした。

私のapp.yamlファイルには、私のファイルの構造がある

application: xxxx 
version: 3 
runtime: php55 
api_version: 1 
threadsafe: yes 

env_variables: 
    # Replace project, instance, database, user and password with the values obtained 
    # when configuring your Cloud SQL instance. 
    MYSQL_DSN: mysql:unix_socket=/cloudsql/xxxxx 
    MYSQL_USER: xxx 
    MYSQL_PASSWORD: 'xxxx' 

handlers: 

- url: /admin/js 
    static_dir: admin/js 

- url: /js 
    static_dir: js 

- url: /fonts/(.*\.otf) 
    static_dir: fonts/\1 
    mime_type: application/x-font-otf 

- url: /css 
    static_dir: css 

- url: /admin/css 
    static_dir: admin/css 

- url: /admin/font-awesome 
    static_dir: admin/font-awesome/\1 
    mime_type: application/x-font-otf 

- url: /admin/fonts 
    static_dir: admin/fonts 
    mime_type: application/x-font-otf 

- url: /admin/images 
    static_dir: admin/images 

- url: /includes/js 
    static_dir: /includes/js 

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

- url: /.* 
    script: index.php 

であり、これは私がthis話題を追っ

image with structure

成功しようとしていますものです。

私のindex.phpコード

<?php require_once("admin/includes/Db_object.php") ?> 
<?php require_once("admin/includes/init.php")?> 
<?php include("includes/header.php"); ?> 

<?php $photos = Photo::find_all();?> 

<div class="row"> 

    <!-- Blog Entries Column --> 
    <div class="col-md-12"> 
    <div class="thumbnails row"> 
     <?php foreach ($photos as $photo): ?> 
      <div class="col-md-4"> 
      <a class = "thumbnail" href="#" data-toggle="lightbox" > 
      <img class="img-responsive home_page_photo" src="admin/<?php echo $photo->picture_path();?>" alt="" ></a> 
      </div> 
      <?php endforeach;?> 
     </div> 
     </div> 
<!-- /.row --> 
<?php include("includes/footer.php"); ?> 

EDIT:これは私のログファイルからの誤差である私はそれを展開

PHP Warning: require_once(C:/Users/xxx/Desktop/MyGallery/admin/includes/new_config.php): failed to open stream: No such file or directory in /base/data/home/apps/s~my-project-test-150523/1.397682853077463759/admin/includes/init.php on line 10 
18:30:31.878 
PHP Fatal error: require_once(): Failed opening required 'C:/Users/xxx/Desktop/MyGallery/admin/includes/new_config.php' (include_path='.;/base/data/home/apps/s~my-project-test-150523/1.397682853077463759/;/base/data/home/runtimes/php/sdk') in /base/data/home/apps/s~my-project-test-150523/1.397682853077463759/admin/includes/init.php on line 10 

答えて

0

scriptファイルパスのリーディング/を削除する必要があります。

- url: /footer.php 
    script: /includes/footer.php 

- url: /header.php 
    script: /includes/header.php 

- url: /navigation.php 
    script: /includes/navigation.php 

- url: /sidebar.php 
    script: /includes/sidebar.php 

はまた、このように、他のタイプミスのチェック:

- url: /admin/edit_photo.php 
    script: admin/dit_photo.php 

汎用の.phpスクリプトハンドラを使用するほうが簡単ではないでしょうか?

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

サイドノート:なぜあなたも短縮/スクリプトのパス(およびプロセスにおけるapp.yamlファイルの内容を汚染による大幅危険エラー)の一部を翻訳しようとする気ないドキュメントExampleに示すようなとき、あなたは実際にあなたのindex.php、例えば、短いバージョンを使用していない:

<?php require_once("admin/includes/Db_object.php") ?> 
<?php require_once("admin/includes/init.php")?> 
<?php include("includes/header.php"); ?> 

あなたがパスの翻訳/短縮をドロップする場合は、上記の一般的なハンドラは、同様にそれらをカバーします。ずっときれい(そしてより安全)。

更新:

他のいくつかの可能性のある問題を(彼らは実際にトラブルが発生したりしていない場合、私はよく分からない)スポッティング許さapp.yamlクリーナー。

あなたが、たとえば、static_dirコンフィグで正規表現のグループ化を使用しようとする試みを持っているようだ:

- url: /fonts/(.*\.otf) 
    static_dir: fonts/\1 
    mime_type: application/x-font-otf 

Handlers elementテーブル内の各行によると、唯一のstatic_filesのconfigsは、このようなグループ化を使用することができます。 2つの設定を切り替えて、グループを削除するのを忘れたのでしょうか?私はちょうどそれを試してみましたが、何も起こらなかった

- url: /admin/font-awesome 
    static_dir: admin/font-awesome/\1 
    mime_type: application/x-font-otf 
+0

あなたが私に言ったようにハンドラを変更し、ローカルで完璧に動作します! (上記の私の新しいapp.yamlを参照してください)。私はそれを展開するとき、私は同じエラーがありますが、私は説明しました....あなたのレスポンに感謝します! –

+0

デベロッパーコンソール(https://console.cloud.google.com/logs)のアプリのリクエストログを確認し、404エラーの原因となったリクエストを探します。あなたの 'index.php'で参照されている他の要素が見つからない可能性があります。他のエラーも関連している可能性があります。 –

+0

私のログファイルを見て、それは台無しです!私はあなたの外観を見てみたい場合は何か新しい質問を編集します –

0

変更最後のハンドラへ:

- url: /.* 
    script: index.php 

これは、上記のハンドラで見つからない要求をに送信します。または、より多くの制御のために:

- url:/
    script: index.php 

- url: /.* 
    script: not_found.php 
+0

は、1つの場合にはあなたがグループ化(\1)が、対応するurl configに無いグループ定義への参照を持っている(...ありがとうございましたあなたの応答 –

+0

あなたの 'index.php'のコードを投稿してください – GAEfan

+0

私はindex.phpを投稿しました:) –