【问题标题】:Including Zend Framework library in php.ini on bluehost server在 bluehost 服务器上的 php.ini 中包含 Zend Framework 库
【发布时间】:2012-05-15 09:36:12
【问题描述】:

我无法在 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]

重写规则 ^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();

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

【问题讨论】:

    标签: zend-framework deployment bluehost


    【解决方案1】:

    看看执行以下操作是否能让你启动并运行:

    • 将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,因为这实际上是您的公用文件夹。

    【讨论】:

    • 虽然我确实想出了一种让它发挥作用的方法,但我还是尝试了您的解决方案。它正在渲染布局,但找不到视图脚本。访问主目录时出现以下错误:在路径 (/home1/wethemen/application/views/scripts/) 中找不到脚本''home'/index.phtml'
    • 不知道在 localhost 上工作的一切似乎都在服务器上中断了。即使是这样的简单操作: $this->url('controller'=>'home', 'action'=>'contact-us'),null,true) 也不起作用。
    • 你有文件/home1/wethemen/application/views/scripts/home/index.phtml吗?这是 ZF 试图渲染的视图脚本。如果找不到视图脚本,该异常是正常的。
    猜你喜欢
    • 1970-01-01
    • 2011-01-25
    • 1970-01-01
    • 1970-01-01
    • 2013-09-19
    • 2011-10-20
    • 1970-01-01
    • 2012-08-03
    • 2012-06-10
    相关资源
    最近更新 更多