天天看點

PHP Smarty無法解析模闆檔案

/******************************************************************************
 *                        PHP Smarty無法解析模闆檔案
 * 說明:
 *     修改為使用Smarty來做模闆解析遇到無法解析檔案的問題,通過檢視Apache伺服器
 * 日志的方式解決。
 *
 *                                         2017-3-12 深圳 南山平山村 曾劍鋒
 *****************************************************************************/

一、現象:
    使用了Smarty之後發現檔案不能被解析,但是在指令行下可以使用php來運作,并直接被解析。

二、解決思路:
    1. 檢視PHP的錯誤日志,但不知到PHP的錯誤日志在哪裡;
    2. 直接看Apache的日志/var/log/apache2/error.log,看到如下這段:
        [Sun Mar 12 22:01:01.115093 2017] [:error] [pid 10446] [client 127.0.0.1:51952] PHP Fatal error:  Uncaught  --> Smarty: unable to write file /home/zengjf/zengjf/zengjfos/ARMDesktop/production/templates/output/templates_c/wrt58c5549d1c15c8_04214133 <-- 
  thrown in /home/zengjf/zengjf/zengjfos/ARMDesktop/production/templates/output/smarty/sysplugins/smarty_internal_runtime_writefile.php on line 49

    3. 由此可見是目錄權限問題導緻,修改目錄權限就可以解決了。