我已经/usr/local/lib/php/Smarty/Smarty.class.php
了,我已将我的Smarty模板,缓存和其他目录放在/home/groucho/Code/PHP/smarty/
中。
这是index.php
中的/var/www/sapienter
文件(这是我的应用文件夹):
<?php
// put full path to Smarty.class.php
require('/usr/local/lib/php/Smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->setTemplateDir('/home/groucho/Code/PHP/smarty/templates');
$smarty->setCompileDir('/home/groucho/Code/PHP/smarty/templates_c');
$smarty->setCacheDir('/home/groucho/Code/PHP/smarty/cache');
$smarty->setConfigDir('/home/groucho/Code/PHP/smarty/configs');
$smarty->testInstall();
$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');
?>
但是这不起作用,因为它给了我这个输出:
Smarty Installation test...
Testing template directory...
FAILED: /home/groucho/Code/PHP/smarty/templates/ does not exist.
Testing compile directory...
FAILED: /home/groucho/Code/PHP/smarty/templates_c/ does not exist.
Testing plugins directory...
/usr/local/lib/php/Smarty/plugins is OK.
Testing cache directory...
FAILED: /home/groucho/Code/PHP/smarty/cache/ does not exist.
Testing configs directory...
FAILED: /home/groucho/Code/PHP/smarty/configs/ does not exist.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.
Fatal error: Uncaught --> Smarty: Unable to load template file 'index.tpl' <-- thrown in /usr/local/lib/php/Smarty/sysplugins/smarty_internal_templatebase.php on line 127
/home/groucho/Code/PHP/smarty
文件夹权限由chmod -R 775
设置,我是所有者。
如果我将templates
文件夹和其他文件夹直接放在/var/www/sapienter
中并且我写了
$smarty->setTemplateDir('/var/www/sapienter/templates');
它有效。
为什么?为什么/var
路径有效且/home
没有?