//设置权限 chown nginx:nginx "4个目录"; chmod 770 "4个目录";
<?php define('SMARTY_DIR','/usr/local/lib/smartyLibs/');//定义lib路径 require_once(SMARTY_DIR.'Smarty.class.php');//引用Smarty库 $smarty=new Smarty();//建立Smarty define('SMARTY_SITE','/var/www/html/site_A/');//定义网站路径 $smarty->setTemplateDir(SMARTY_SITE.'templates'); $smarty->setCompileDir(SMARTY_SITE.'templates_c'); $smarty->setConfigDir(SMARTY_SITE.'configs'); $smarty->setCacheDir(SMARTY_SITE.'cache'); $smarty->left_delimiter='{{'; $smarty->right_delimiter='}}'; $smarty->caching=false;//是否使用缓存 //$smarty->testInstall();//调试用,显示4个目录可读写状态 ?>
<?php include('./smarty.ini.php');//引用smarty.ini.php配置文件 $name='YangGe123';//自定义变量 $smarty->assign('name',$name);//将变量赋予smarty值'name' $smarty->display('index.tpl');//在templates中引用对应的模板 ?>
<html>
<head></head>
<body>
<h1>{$name}</h1>
</body>
</html>
扩展知识:php
调试php,让服务器显示php错误信息:html
修改php.ini文件,将 display_error = off 改成 onnginx
重启php服务缓存
service php-fpm restart服务器