【发布时间】:2014-11-15 18:36:11
【问题描述】:
我正在为我的 Zend Framework 应用程序使用托管解决方案,但无法让它加载 application/bootstrap.php 文件。
当我通过 ftp 访问服务器时,我的文档根目录是 /webspace/httpdocs/euro.millionsresults.com
我将应用程序、公共、库等目录放在此目录中。
然后我根据http://akrabat.com/zend-framework/zend-framework-on-a-shared-host/创建了一个.htaccess
/webspace/httpdocs/euro.millionsresults.com/.htaccess
RewriteEngine On
RewriteRule .* index.php
这会将所有内容重写到我的 index.php 文件中,然后该文件包含 ZF 的 public/index.php 文件,这是正确的并且可以正常工作。 index.php 文件为:
/webspace/httpdocs/euro.millionsresults.com/index.php
<?php
include 'public/index.php';
如果我在 public/index.php 文件中添加一个回显,它可以正常工作,证明当您尝试访问该站点时现在调用了 public/index.php。
问题是,public/index.php 文件需要包含 ../application/bootstrap.php 文件:
/webspace/httpdocs/euro.millionsresults.com/public/index.php
<?php
echo "this is working";
require('../application/bootstrap.php');
但是,application/bootstrap.php 不包含在内。
如果我在 application/bootstrap.php 的最顶部放置一个骰子,则不会渲染任何内容。
我已经为 public/index.php 尝试了以下内容:
require('../../../application/bootstrap.php'); 要求('/webspace/httpdocs/euro.millionsresults.com/application/bootstrap.php');
但是在包含 application/bootstrap.php 时没有任何作用。
有人知道在这里做什么吗?这是我使用的廉价主机,无法访问 php.ini。
其他信息:
问题似乎出在 include_path 上。当我执行 get_include_path() 时,我有:
:/php/includes:/usr/share/pear:/usr/libexec/php4-cgi/share/pear:/opt/alt/php55/usr/share/pear:/opt/alt/php54/usr/share/pear:/opt/alt/php53/usr/share/pear
我可以设置_include_path(),但是我要设置什么?
我试过了:
set_include_path('/webspace/httpdocs/euro.millionsresults.com/application' . PATH_SEPARATOR. get_include_path());
set_include_path('/../../../application' . PATH_SEPARATOR . get_include_path());
set_include_path('../application' . PATH_SEPARATOR . get_include_path());
这些都不起作用,即当我的 public/index.php 文件中有以下内容时,我总是得到“不存在”:
<?php
echo "In file public/index.php <br>";
set_include_path('/../../../application' . PATH_SEPARATOR . get_include_path());
echo get_include_path();
if (file_exists('/../application/bootstrap.php')){
echo "<br>exists";
}
else {
echo "<br>does not exist";
}
我检查存在的文件无关紧要 - 找不到应用程序文件夹中的任何文件,或任何不公开的文件夹。
【问题讨论】:
-
这个文件夹的权限是什么?它的所有者是哪个用户/组?
-
我的 zend 框架 .htaccess 文件是: RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L]
-
我的 Zend .htaccess 文件也不一样,我上面贴的 .htaccess 只是将所有内容重定向到 doc 根目录下的 index.php,然后调用 ZF public/index.php 文件。
-
权限为 755,所有者与所有其他目录的所有者相同。
-
我认为 .htaccess 文件是导致此问题的原因。还需要使用 realpath(dirname(FILE) . '/../application'))
标签: php zend-framework