2017-06-12 114 views
1

我有一个非常基本的功能,我开始。我在code/Page.php开始非常简单,:SilverStripe - 模板变量抛出错误

public function createGreeting() { 
    return 'hi'; 
} 

在我Page.ss模板,我有自己的变量:<% $createGreeting %>

然而,这是杀网页。我检查了错误日志,它显示:

PHP message: PHP Warning: Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set. in /usr/share/nginx/html/lungmap/framework/control/Director.php on line 488" while reading upstream, client: 31.210.102.114, server: 52.90.93.59, request: "GET/HTTP/1.0", upstream: "fastcgi://unix:/var/run/php/php5.6-fpm.sock:" 2017/06/12 12:34:50 [error] 1730#0: *6682 FastCGI sent in stderr: "PHP message: PHP Warning: Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set. in /usr/share/nginx/html/lungmap/framework/control/Director.php on line 488 

任何想法可能导致这种情况?如果我从Page.ss中删除该行,页面加载完全正常。

+0

你可以分享你的nginx配置吗?你有没有使用[文档中的示例](https://docs.silverstripe.org/en/3/getting_started/installation/how_to/configure_nginx/)开始,或者推出自己的?无论如何,它看起来像nginx没有设置['$ http_host'参数](https://stackoverflow.com/questions/15414810/whats-the-difference-of-host-and-http-host-in-nginx )正确。 –

回答

6

您不应该将变量包装在<% %>块中,而只需调用它。

+1

/headdesk谢谢! – yondaimehokage