0

Bluehost サーバーで ZF ライブラリのインクルード パスを正しく設定できません。

ディレクトリ構造は次のとおりです。

/root_directory

 .htaccess

 __/Zend

 __Application(from ZF)

 __library(from ZF)

 __/public_html

    __/public(the ZF public folder)

public フォルダーから .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]

RewriteRule ^public/.*$ /public/index.php [NC,L]

public フォルダー内の 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();

私のプロジェクトをサーバーにデプロイするのを手伝ってください。他に言及する必要がある場合は、お知らせください。

4

1 に答える 1

0

以下を実行すると、起動して実行できるかどうかを確認します。

  • の内容をフォルダに移動public_html/publicpublic_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

基本的に、唯一の変更点は、publicZend Framework に付属のフォルダーを実際に使用する代わりに、実際にpublic_htmlはパブリック フォルダーであるため、代わりに に置き換えることです。

于 2012-05-15T21:44:33.653 に答える