2017-06-12 116 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