【问题标题】:Google App Engine Failed opening SMARTY php scriptsGoogle App Engine 无法打开 SMARTY php 脚本
【发布时间】:2015-01-21 22:08:15
【问题描述】:

我正在使用 Google App Engine (GAE) 进行 Web 开发以及 Smarty html模板引擎。

这是我在 include.php 中使用的代码段。在我部署之后 它显示我没有输出并显示这些日志。

<?php
include_once(dirname(dirname(__FILE__)) . '/includes/configs/config.inc.php');

if (!isset($_SESSION))
    session_start();

$_SESSION['timestamp'] = time();

if (isset($_SESSION['auth']) && $_SESSION['auth'] === true)
    $authStatus = true;

include_once(INCLUDE_DIR . '/library/util.php');
include_once(INCLUDE_DIR . '/library/connection.php');
include_once(CLASSES_DIR . 'db.class.php');
include_once(INCLUDE_DIR . '/langs/en.lang.php');
include_once(INCLUDE_DIR . '/helpers/browserDetect.class.php');

这将是我的日志输出

PHP 警告:include_once():open_basedir 限制生效。文件(/base/data/home/apps/s~/includes/configs/config.inc.php) 不在允许的路径内:(/base/data/home/apps/s~/1.380323599570411257/;/base/data/home/runtimes/php/sdk;/php_runtime/versions;/etc) 在 /base/data/home/apps/s~**/1.380323599570411257/includes.php 上线2

PHP 警告:include_once(/base/data/home/apps/s~/includes/configs/config.inc.php):无法打开流:/base/data/home/ 中不允许操作apps/s~/1.380323599570411257/includes.php 在第 2 行

这将是我的 app.yaml

application: ***
version: 1
runtime: php
api_version: 1

handlers:
- url: /css
  static_dir: css

- url: /images
  static_dir: images

- url: /js
  static_dir: js

- url: /
  script: index.php

- url: /(.+)$
  script: index.php

【问题讨论】:

    标签: php google-app-engine smarty yaml google-cloud-sql


    【解决方案1】:

    我将 app.yaml 文件放在 docroot 之外。 我将 app.yaml 更新为类似的内容,它对我有用

    application: creditcard-deals
    version: 1
    runtime: php
    api_version: 1
    
    handlers:
    - url: /css
      static_dir: css
    
    - url: /images
      static_dir: images
    
    - url: /js
      static_dir: js
    
    - url: /(.*/)?.*\.tpl
      mime_type: application/vnd.trid.tpt
      static_files: tpl
      upload: static/(.*\.tpl)
    
    - url: (.+).php
      script: \1.php
    
    - url: /.*
      script: /docroot/index.php
    

    【讨论】:

      【解决方案2】:

      您对 dirname 的调用次数过多,请尝试

      <?php
      include_once(dirname(__FILE__) . '/includes/configs/config.inc.php');
      

      【讨论】:

      • 我试过了,但它仍然显示这个日志。 '0 PHP 警告:include_once(/base/data/home/apps/s~creditcard-deals/1.380325141954686891/includes/configs/config.inc.php):无法打开流:/base/data 中没有这样的文件或目录/home/apps/s~creditcard-deals/1.380325141954686891/includes.php 在第 2 行'
      • 我只需要后退一个目录。
      猜你喜欢
      • 2012-12-27
      • 1970-01-01
      • 2015-05-15
      • 2011-02-03
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 2014-04-16
      相关资源
      最近更新 更多