我在Linux上使用Php Smarty。我的smarty模板不顯示
我在我的PHP文件中的一行:
$phpsmart->display("pagetemplate.tpl");
這條線應該顯示pagetemplate.tpl
。它沒有。
我在Linux上使用Php Smarty。我的smarty模板不顯示
我在我的PHP文件中的一行:
$phpsmart->display("pagetemplate.tpl");
這條線應該顯示pagetemplate.tpl
。它沒有。
即使更改文件權限和文件所有權,它也不會顯示tpl文件。
適用於有此類問題的人。
1)chmod -R 755/var/www - >這將爲組的所有者和其他人(所有者所有)以及其他人在讀取和執行時授予讀寫權限。這是遞歸地分配,所以你所有的文件和目錄www內部也將具有相同的權限
2)chown -R apache:apache/var/www - >這將使apache所有者的www和包括文件。這也是遞歸應用的。
3)您的網站所有者需要向template_c文件寫入權限,因此請使用ls -altr檢查是否已授予寫入權限,如果寫入類似於755(rwxr-xr-x)並且仍然無法將其更改爲777(記得chmod)。也檢查緩存文件夾..
4)如果仍然不工作可能是selinux正在保護您的template_c文件的寫入訪問。所以你需要下面的命令
setsebool -P httpd_unified=1 -> This will disable selilnux for apache httpd.
享受!
啓用錯誤或檢查您的日誌。最有可能的是你沒有設置smarty需要的可寫目錄。
我剛安裝了智者與作曲家:
$ composer.phar require smarty/smarty
而且嘗試了演示:
(!) Fatal error: Uncaught --> Smarty: unable to write file ./templates_c/wrt56681191371d80_85949214 <-- thrown in /var/www/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46
然後我創建了一個 'template_c' 文件夾,並使其可寫Web服務器。
(!) Fatal error: Uncaught --> Smarty: unable to write file ./cache/wrt566812bd6f7b08_17223124 <-- thrown in /var/www/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46
然後我創建了'cache'文件夾,並且使它可以被web服務器寫入。
該演示工作。
你檢查了你的錯誤日誌嗎? – Progrock
有沒有錯誤 –
也許你沒有顯示錯誤? http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display – Progrock