2012-05-15 43 views
0

我無法在Bluehost服務器上正確設置ZF庫的include路徑。在Bluehost服務器上的php.ini中包含Zend Framework庫

這裏的目錄結構:

/root_directory 

.htaccess 

__/Zend 

__Application(from ZF) 

__library(from ZF) 

__/public_html 

    __/public(the ZF public folder) 

我從公共文件夾中刪除了的.htaccess並將其放置在ROOT_DIRECTORY。的.htaccess的

內容:

RewriteEngine On 

RewriteRule ^.htaccess$ - [F] 
RewriteCond %{REQUEST_URI} ="" 
RewriteRule ^.*$ /public/index.php [NC,L] 


RewriteCond %{REQUEST_URI} !^/public/.$ 
RewriteRule ^(.)$ /public/$1 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule ^.*$ - [NC,L] 

重寫規則^公共/.*$ /public/index.php [NC,L]公用文件夾在index.php中的

內容:

// 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' 
); 
$FrontController = Zend_Controller_Front::getInstance(); 
$Router=$FrontController->getRouter(); 

    Zend_Layout::startMvc(array(
    "layout" => "layout", 
    "layoutPath" => "layouts/scripts" 
    )); 

$plugin=new Zend_Controller_Plugin_ErrorHandler(); 
$plugin->setErrorHandler(array("controller" =>'ApplicationError', 
           "action"=>'index')); 
$FrontController->registerPlugin($plugin); 

$application->bootstrap() 
      ->run(); 

請幫助我在服務器上部署我的項目。如果還有什麼我需要提及請讓我知道。

回答

0

看看執行以下操作讓你和運行:

  • public_html/public移動內容到public_html並刪除public文件夾
  • 刪除root_directory/.htaccess
  • 創建public_html/.htaccess

public_html/.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] 
  • index.php文件看起來不錯,沒有必要改變APPLICATION_PATH

基本上,唯一的變化是,不是實際使用與Zend框架附帶的public文件夾,你public_html替換它,而不是因爲這是真正的公共文件夾。

+0

雖然我確實找到了一個讓它工作一點的方法,但我嘗試了一下您的解決方案。它是渲染布局,但找不到視圖腳本。當我訪問主目錄時出現以下錯誤:script''home'/ index.phtml'找不到路徑(/ home1/wethemen/application/views/scripts /) –

+0

不知道在localhost上的所有東西打破服務器。即使是一個簡單的東西,如:$ this-> url('controller'=>'home','action'=>'contact-us'),null,true)不起作用。 –

+0

你有文件'/ home1/wethemen/application/views/scripts/home/index.phtml'嗎?這是ZF試圖呈現的視圖腳本。如果找不到視圖腳本,這個例外是正常的。 – drew010

相關問題