在bluehost服务器上的php.ini中包含Zend Framework库

时间:2012-05-15 09:36:12

标签: zend-framework deployment bluehost

我无法在Bluehost服务器上正确设置ZF库的包含路径。

这是目录结构:

/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]

RewriteRule ^ public /.*$ /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();

请帮我在服务器上部署我的项目。如果还有什么我需要提的,请告诉我。

1 个答案:

答案 0 :(得分: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 Framework附带的public文件夹,而是将其替换为public_html,因为这实际上是您的公用文件夹。