2013-10-15 33 views
3

我的索引文件是这样的警告:require_once(的Zend/Application.php):未能打开流:在/ var没有这样的文件或目录/ W

<?php 
ini_set("short_open_tag", 1); 
ini_set("display_errors", 1); 
// Define path to application directory 

defined('APPLICATION_PATH') 
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); 
// Define application environment 
defined('APPLICATION_ENV') 
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); 

// Ensure library/ is on include_path 
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'), 
    get_include_path(), 
))); 
/** Zend_Application */ 
require_once 'Zend/Application.php'; 

// Create application, bootstrap, and run 
$application = new Zend_Application(
    APPLICATION_ENV, 
    APPLICATION_PATH . '/configs/application.ini' 
); 

// Let 'er rip 
$application->bootstrap()->run(); 

当我运行

警告:require_once(Zend/Application.php):未能打开流:在第18行的/var/www/Giftercity_backup/index.php中没有这样的文件或目录致命错误:require_once():无法打开所需的'Zend/Application.php '(include_path =':。:/ usr/share/php:/ usr/share/pear')在/var/www/Giftercity_backup/index.php在线18

+0

一个经常运行到这个错误,并迅速解决它,请按照下列步骤操作:https://stackoverflow.com/a/36577021/2873507 –

回答

0

如果您的index.php文件位于/var/www/Giftercity_backup/index.php(根据错误输出),则根据您的代码library的位置应该在/var/www/libraryapplication,/var/www/application这听起来不对。

index.php应位于公用文件夹中,如/var/www/Giftercity_backup/public,/var/www/Giftercity_backup/htdocs或类似文件,您的VirtualHost DocumentRoot应该指向该文件夹。

此外,您的set_include_path未注册library(include_path =':。:/ usr/share/php:/ usr/share/pear')。

+0

现在有这这里经常错误的故障排除清单: https://stackoverflow.com/a/36577021/2873507 –

1

将您的索引文件放在“公共”目录中。

或者,如果你想或不能包括从父目录中的文件,你需要改变这一行:

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'), 
    get_include_path(), 
))); 

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/library'), // Here we have change 
    get_include_path(), 
))); 

当然,我假设你已经推杆您的Zend文件成库/ Zend

您还需要记住将.htaccess文件与“拒绝所有”放到您的应用程序,库和任何其他您不希望用户的目录中获得访问权限。

Btw。 这种包含库的方法相当陈旧,不推荐使用。

5

对于Ubuntu。
如果您安装了ZendFramework包。即sudo apt-get install zend-framework
它将把Zend库文件/usr/share/php/libzend-framework-php/Zend/ folder
你把刚才复制并粘贴Zend/ folder into /user/share/php/
运行在终端下面的命令。

cd /usr/share/php 
sudo cp -R libzend-framework-php/Zend/ Zend 
+3

我会创建一个符号链接,但你的回答基本上是我所做的 –

+0

@ Angel.King.47是的,你也可以这样做。 – chanchal

+0

对于debian apt-get install zendframework – relipse

相关问题