zoukankan      html  css  js  c++  java
  • Nginx.PHP配置Smarty

    1. 下载http://smarty.net;
    2. 解压 -> 将 libs 文件夹重命名 smartyLibs -> 放置在自己服务器的 usr/local/lib/ 中 (/usr/local/lib/smartyLibs);
    3. 在网站目录,如 site_A 中 创建 4 个必须文件夹 templates、templates_c、configs、cache
      //设置权限
      chown nginx:nginx "4个目录";
      chmod 770 "4个目录";
    4. 在网站目录中创建 smarty.ini.php 配置文件(smarty基本配置信息),内容如下
      <?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个目录可读写状态
      ?>
    5. 创建网站页面文件 index.php
      <?php
      include('./smarty.ini.php');//引用smarty.ini.php配置文件
      $name='YangGe123';//自定义变量
      $smarty->assign('name',$name);//将变量赋予smarty值'name'
      $smarty->display('index.tpl');//在templates中引用对应的模板
      ?>
    6. 在Templates中创建网站对应的模板
      <html>
          <head></head>
          <body>
              <h1>{$name}</h1>
          </body>
      </html>

    扩展知识:

    调试php,让服务器显示php错误信息:

    修改php.ini文件,将 display_error = off 改为 on

    重启php服务

    service php-fpm restart

  • 相关阅读:
    一次Oracle数据迁移
    mysql Error Handling and Raising in Stored Procedures
    expdp ORA-39213
    RHEL 6.4 64bit kettle5.01导入xlsx格式的excel时报错
    Oracle表空间传输测试
    oracle expdp 无法导出SYS下特定TABLE
    Oracle wrap 测试的一些细节问题
    论文-CondenseNet: An Efficient DenseNet using Learned Group Convolutions
    SystemVerilog-断言
    推挽输出和开漏输出
  • 原文地址:https://www.cnblogs.com/enone/p/4118857.html
Copyright © 2011-2022 走看看