【问题标题】:Setting Up Zend Framework 2 On A Live Server在 Live 服务器上设置 Zend Framework 2
【发布时间】:2014-06-09 10:16:45
【问题描述】:

我正在尝试在实时服务器上设置我的第一个 Live 站点,我使用的是共享主机帐户,因此我无法将我的 DocumentRoot 更改为指向网站 。

不过,我确实遵循了here: 的建议,并在站点的根目录中创建了两个文件;

index.php 和一个 .htaccess

不幸的是,我的网站完全空白;什么都没有被渲染。因此,我想知道是否还需要做其他事情来渲染类。

这是我的 index.php 文件

define('RUNNING_FROM_ROOT', true);
include 'public/index.php';

这是我的 .htaccess 文件

SetEnv APPLICATION_ENV production

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 

【问题讨论】:

  • 您如何将站点托管为子域或主域或子文件夹访问,子文件夹访问在共享托管中不起作用,因为对 zf2 的所有引用都来自 / [root]
  • 白页通常表示php错误。尝试将ini_set("display_errors", 1); 添加到您的 index.php 文件中以查看实际情况

标签: zend-framework2


【解决方案1】:

您遵循的说明是为 ZF1 编写的。

尝试在您的公共文件夹中创建一个新的 .htaccess 文件,如下所示:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

这是Zend Skeleton Application 中 apache2 的推荐方式。既然你不想做完全不同的事情,它应该可以工作。

【讨论】:

  • 嗨笨蛋。感谢您的回复。我试过了,但它不起作用。我仍然得到一个空白页
  • 我确实觉得问题出在 zendframework 上。例如,如果我从我的公共文件夹中的索引页面回显“test”,它确实会回显测试。
  • 嗨笨蛋。你是个天才。谢谢你的帮助 。它现在工作
【解决方案2】:

这可能是由于代码中的空格造成的。 要删除空格,您可以使用它 PHP CS Fixer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-26
    • 2013-01-30
    • 2012-08-15
    • 2011-10-20
    • 1970-01-01
    • 2015-04-18
    相关资源
    最近更新 更多